login: avoid leak of name returned by uid_to_name()
This commit is contained in:
parent
c05107767b
commit
e99742ef3e
|
@ -2157,6 +2157,7 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
|
||||||
|
|
||||||
if (cancelled && m->enable_wall_messages) {
|
if (cancelled && m->enable_wall_messages) {
|
||||||
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
|
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
|
||||||
|
_cleanup_free_ char *username = NULL;
|
||||||
const char *tty = NULL;
|
const char *tty = NULL;
|
||||||
uid_t uid = 0;
|
uid_t uid = 0;
|
||||||
int r;
|
int r;
|
||||||
|
@ -2167,8 +2168,9 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
|
||||||
(void) sd_bus_creds_get_tty(creds, &tty);
|
(void) sd_bus_creds_get_tty(creds, &tty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
username = uid_to_name(uid);
|
||||||
utmp_wall("The system shutdown has been cancelled",
|
utmp_wall("The system shutdown has been cancelled",
|
||||||
uid_to_name(uid), tty, logind_wall_tty_filter, m);
|
username, tty, logind_wall_tty_filter, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sd_bus_reply_method_return(message, "b", cancelled);
|
return sd_bus_reply_method_return(message, "b", cancelled);
|
||||||
|
|
|
@ -61,7 +61,7 @@ bool logind_wall_tty_filter(const char *tty, void *userdata) {
|
||||||
|
|
||||||
static int warn_wall(Manager *m, usec_t n) {
|
static int warn_wall(Manager *m, usec_t n) {
|
||||||
char date[FORMAT_TIMESTAMP_MAX] = {};
|
char date[FORMAT_TIMESTAMP_MAX] = {};
|
||||||
_cleanup_free_ char *l = NULL;
|
_cleanup_free_ char *l = NULL, *username = NULL;
|
||||||
usec_t left;
|
usec_t left;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -83,8 +83,8 @@ static int warn_wall(Manager *m, usec_t n) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
utmp_wall(l, uid_to_name(m->scheduled_shutdown_uid),
|
username = uid_to_name(m->scheduled_shutdown_uid);
|
||||||
m->scheduled_shutdown_tty, logind_wall_tty_filter, m);
|
utmp_wall(l, username, m->scheduled_shutdown_tty, logind_wall_tty_filter, m);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue