[VODZ] crontab question

Bernhard Fischer rep.nop at aon.at
Tue Jan 10 09:54:21 UTC 2006


Hi vodz,

I don't understand the logic in crontab.c, ChangeUser().
Do you perhaps mean cd $HOME || cd /tmp (i.e. without the first
bb_perror_msg_and_die()?

Please fix, TIA.

-------------- next part --------------
Index: miscutils/crontab.c
===================================================================
--- miscutils/crontab.c	(revision 13104)
+++ miscutils/crontab.c	(working copy)
@@ -59,6 +59,8 @@
     char caller[256];           /* user that ran program */
     int   UserId;
 
+   /* record the caller first.  */
+
     UserId = getuid();
     if ((pas = getpwuid(UserId)) == NULL)
 	bb_perror_msg_and_die("getpwuid");
@@ -342,7 +344,7 @@
      * Obtain password entry and change privileges
      */
 
-    if ((pas = getpwnam(user)) == 0) {
+    if ((pas = getpwnam(user)) == NULL) {
 	bb_perror_msg_and_die("failed to get uid for %s", user);
 	return(-1);
     }
@@ -358,10 +360,12 @@
     if (dochdir) {
 	if (chdir(pas->pw_dir) < 0) {
 	    bb_perror_msg_and_die("chdir failed: %s %s", user, pas->pw_dir);
+#error Never get here  ---v
 	    if (chdir(TMPDIR) < 0) {
 		bb_perror_msg_and_die("chdir failed: %s %s", user, TMPDIR);
 		return(-1);
 	    }
+#error so why not remove this block? ---^
 	}
     }
     return(pas->pw_uid);


More information about the busybox mailing list