su: cleanup code to copy to log strings
man utmp: String fields are terminated by a null byte ('\0') if they are shorter than the size of the field. Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
ac5c12fdc2
commit
7f76bc8a75
|
@ -609,14 +609,14 @@ static void log_btmp(struct su_context *su)
|
||||||
DBG(LOG, ul_debug("btmp logging"));
|
DBG(LOG, ul_debug("btmp logging"));
|
||||||
|
|
||||||
memset(&ut, 0, sizeof(ut));
|
memset(&ut, 0, sizeof(ut));
|
||||||
strncpy(ut.ut_user,
|
str2memcpy(ut.ut_user,
|
||||||
su->pwd && su->pwd->pw_name ? su->pwd->pw_name : "(unknown)",
|
su->pwd && su->pwd->pw_name ? su->pwd->pw_name : "(unknown)",
|
||||||
sizeof(ut.ut_user));
|
sizeof(ut.ut_user));
|
||||||
|
|
||||||
if (su->tty_number)
|
if (su->tty_number)
|
||||||
xstrncpy(ut.ut_id, su->tty_number, sizeof(ut.ut_id));
|
str2memcpy(ut.ut_id, su->tty_number, sizeof(ut.ut_id));
|
||||||
if (su->tty_name)
|
if (su->tty_name)
|
||||||
xstrncpy(ut.ut_line, su->tty_name, sizeof(ut.ut_line));
|
str2memcpy(ut.ut_line, su->tty_name, sizeof(ut.ut_line));
|
||||||
|
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
ut.ut_tv.tv_sec = tv.tv_sec;
|
ut.ut_tv.tv_sec = tv.tv_sec;
|
||||||
|
|
Loading…
Reference in New Issue