]> rtime.felk.cvut.cz Git - sojka/lightdm.git/commitdiff
Don't set utmp variables if they aren't known
authorRobert Ancell <robert.ancell@canonical.com>
Thu, 25 Jul 2013 04:34:09 +0000 (16:34 +1200)
committerRobert Ancell <robert.ancell@canonical.com>
Thu, 25 Jul 2013 04:34:09 +0000 (16:34 +1200)
src/session-child.c

index 0f22d240e215cec6579190bb8209a96d6fc00883..138f3188d2dffc09e2dad99360d6150ed6023347 100644 (file)
@@ -609,8 +609,10 @@ session_child_run (int argc, char **argv)
             memset (&ut, 0, sizeof (ut));
             ut.ut_type = USER_PROCESS;
             ut.ut_pid = child_pid;
-            strncpy (ut.ut_line, tty + strlen ("/dev/"), sizeof (ut.ut_line));
-            strncpy (ut.ut_id, xdisplay, sizeof (ut.ut_id));
+            if (tty)
+                strncpy (ut.ut_line, tty + strlen ("/dev/"), sizeof (ut.ut_line));
+            if (xdisplay)
+                strncpy (ut.ut_id, xdisplay, sizeof (ut.ut_id));
             strncpy (ut.ut_user, username, sizeof (ut.ut_user));
             if (xdisplay)
                 strncpy (ut.ut_host, xdisplay, sizeof (ut.ut_host));
@@ -638,8 +640,10 @@ session_child_run (int argc, char **argv)
             memset (&ut, 0, sizeof (ut));
             ut.ut_type = DEAD_PROCESS;
             ut.ut_pid = child_pid;
-            strncpy (ut.ut_line, tty + strlen ("/dev/"), sizeof (ut.ut_line));
-            strncpy (ut.ut_id, xdisplay, sizeof (ut.ut_id));
+            if (tty)
+                strncpy (ut.ut_line, tty + strlen ("/dev/"), sizeof (ut.ut_line));
+            if (xdisplay)
+                strncpy (ut.ut_id, xdisplay, sizeof (ut.ut_id));
             strncpy (ut.ut_user, username, sizeof (ut.ut_user));
             if (xdisplay)
                 strncpy (ut.ut_host, xdisplay, sizeof (ut.ut_host));