Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37373104
en ru br
ALT Linux repos
S:1.3-alt2.qa1
5.0: 1.3-alt2
4.1: 1.3-alt2
4.0: 1.3-alt2
3.0: 1.3-alt2

Group :: System/Base
RPM: chrootuid

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: chrootuid-1.3-alt.patch
Download


--- chrootuid-1.3/chrootuid.c.orig	2002-12-11 15:28:44 +0200
+++ chrootuid-1.3/chrootuid.c	2002-12-11 15:42:57 +0200
@@ -50,9 +50,11 @@
 
 #include <unistd.h>
 #include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
 #include <pwd.h>
 #include <grp.h>
-#include <syslog.h>
 
 int     main(argc, argv)
 int     argc;
@@ -65,12 +67,6 @@
      * require only two arguments.
      */
 
-#ifdef LOG_DAEMON
-    (void) openlog(argv[0], LOG_PID | LOG_NDELAY, LOG_DAEMON);
-#else
-    (void) openlog(argv[0], LOG_PID);
-#endif
-
     /*
      * Require proper amount of arguments. In all cases of error, exit with
      * zero status because we have already reported the problem via syslogd.
@@ -78,44 +74,44 @@
      */
 
     if (argc < 4) {
-	syslog(LOG_ERR, "usage: %s path user command", argv[0]);
-	return (0);
+	fprintf(stderr,"usage: %s path user command\n", argv[0]);
+	return (1);
     }
     /* Must step into the new subtree. */
 
     if (chdir(argv[1])) {
-	syslog(LOG_ERR, "chdir(%s): %m", argv[1]);
-	return (0);
+	fprintf(stderr, "chdir(%s): %s\n", argv[1], strerror(errno));
+	return (1);
     }
     /* The user must be known in the *unrestricted* universe... */
 
     if ((pwd = getpwnam(argv[2])) == 0) {
-	syslog(LOG_ERR, "%s: user unknown", argv[2]);
-	return (0);
+	fprintf(stderr, "%s: user unknown\n", argv[2]);
+	return (1);
     }
     /* initgroups() accesses the group file in the unrestricted universe... */
 
     if (initgroups(pwd->pw_name, pwd->pw_gid) < 0) {
-	syslog(LOG_ERR, "initgroups: %m");
-	return (0);
+	fprintf(stderr, "initgroups: %s\n", strerror(errno));
+	return (1);
     }
     endgrent();
 
     /* Do the chroot() before giving away root privileges. */
 
     if (chroot(argv[1])) {
-	syslog(LOG_ERR, "chroot(%s): %m", argv[1]);
-	return (0);
+	fprintf(stderr, "chroot(%s): %s\n", argv[1], strerror(errno));
+	return (1);
     }
     /* Switch group id then user id. */
 
     if (setgid(pwd->pw_gid)) {
-	syslog(LOG_ERR, "setgid(%d): %m", pwd->pw_gid);
-	return (0);
+	fprintf(stderr, "setgid(%d): %s\n", pwd->pw_gid, strerror(errno));
+	return (1);
     }
     if (setuid(pwd->pw_uid)) {
-	syslog(LOG_ERR, "setuid(%d): %m", pwd->pw_uid);
-	return (0);
+	fprintf(stderr, "setuid(%d): %s\n", pwd->pw_uid, strerror(errno));
+	return (1);
     }
     /* In case we still have the /etc/passwd file still open. */
 
@@ -124,6 +120,6 @@
     /* Run the command and hope for the best. */
 
     (void) execv(argv[3], argv + 3);
-    syslog(LOG_ERR, "%s: %m", argv[3]);
-    return (0);
+    fprintf(stderr, "%s: %s", argv[3], strerror(errno));
+    return (1);
 }
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin