Shutdown: use PATH_DEFAULT as suggested by Paul Arthur in local bug #36101
authorDr. Werner Fink <werner@suse.de>
Thu, 11 Oct 2012 13:10:40 +0000 (13:10 +0000)
committerDr. Werner Fink <werner@suse.de>
Thu, 11 Oct 2012 13:10:40 +0000 (13:10 +0000)
Killall5/pidof: handle strange names of executables (local bug #36252)
Sulogin: be aware the crypt(3) may fail (local bug #36313)

git-svn-id: svn://svn.sv.gnu.org/sysvinit/sysvinit/trunk@117 456724a4-4300-0410-8514-c89748c515a2

doc/Changelog
src/killall5.c
src/shutdown.c
src/sulogin.c

index 8b5a28d993106cc1b03ddbb585ae7036df60c5c7..09ea0e31e252f33a7fddd63193170a97b96cb35e 100644 (file)
@@ -39,6 +39,9 @@ sysvinit (2.89dsf) UNRELEASED; urgency=low
     was specified.
   * Sulogin: if zero is read at reading the passwd guess it's done.
   * Sulogin: respect byte order that is do not mix chars and ints
+  * Shutdown: use PATH_DEFAULT as suggested by Paul Arthur in local bug #36101
+  * Killall5/pidof: handle strange names of executables (local bug #36252)
+  * Sulogin: be aware the crypt(3) may fail (local bug #36313)
 
   [ Petter Reinholdtsen ]
   * Next release will be 2.89dsf.
index 853acb2d1a2158c27ffb42ffa821158e521217d4..54176c3e9494a0699a5488babb0b7fe886b74310 100644 (file)
@@ -508,8 +508,10 @@ int readproc(int do_stat)
 
                /* Read SID & statname from it. */
                if ((fp = fopen(path, "r")) != NULL) {
-                       if (!fgets(buf, sizeof(buf), fp))
-                               buf[0] = '\0';
+                       size_t len;
+
+                       len = fread(buf, sizeof(char), sizeof(buf)-1, fp);
+                       buf[len] = '\0';
 
                        if (buf[0] == '\0') {
                                nsyslog(LOG_ERR,
index 384b4ff1558396e032806e0858c47b10dc8d67b9..dc3eab0710ca387609571af23924f8cb45555fb4 100644 (file)
@@ -76,7 +76,7 @@ int got_alrm = 0;
 
 char *clean_env[] = {
        "HOME=/",
-       "PATH=/bin:/usr/bin:/sbin:/usr/sbin",
+       "PATH=" PATH_DEFAULT,
        "TERM=dumb",
        "SHELL=/bin/sh",
        NULL,
index 45f5f5f5ce838c6883d21b0db4faa1705ebd485b..3775cb781e67598e2f60b9fbb540f5a9a1c2e66a 100644 (file)
@@ -961,19 +961,30 @@ int main(int argc, char **argv)
                        while (1) {
                                char *passwd = pwd->pw_passwd;
                                char *answer;
-                               int failed = 0;
+                               int failed = 0, doshell = 0;
 
                                doprompt(passwd, con);
                                if ((answer = getpasswd(con)) == NULL)
                                        break;
 
-                               if (passwd[0] == '\0' ||
-                                   strcmp(crypt(answer, passwd), passwd) == 0) {
+                               if (passwd[0] == '\0')
+                                       doshell++;
+                               else {
+                                       char *cryptbuf;
+                                       cryptbuf = crypt(answer, passwd);
+                                       if (cryptbuf == NULL)
+                                               fprintf(stderr, "sulogin: crypt failed: %m\n\r");
+                                       else if (strcmp(cryptbuf, pwd->pw_passwd) == 0)
+                                               doshell++;
+                               }
+
+                               if (doshell) {
                                        *usemask |= (1<<con->id);
                                        sushell(pwd);
                                        *usemask &= ~(1<<con->id);
                                        failed++;
                                }
+
                                signal(SIGQUIT, SIG_IGN);
                                signal(SIGTSTP, SIG_IGN);
                                signal(SIGINT,  SIG_IGN);
@@ -987,7 +998,7 @@ int main(int argc, char **argv)
                        }
                        if (alarm_rised) {
                                tcfinal(con);
-                               printf("Timed out.\n\r");
+                               fprintf(stderr, "Timed out.\n\r");
                        }
                        /*
                         *      User may pressed Control-D.