More TANDEM changes
authorWayne Davison <wayne@opencoder.net>
Mon, 6 Jul 2020 07:00:36 +0000 (00:00 -0700)
committerWayne Davison <wayne@opencoder.net>
Mon, 6 Jul 2020 07:05:46 +0000 (00:05 -0700)
- Handle a non-0 root uid.
- Handle alternate major/minor/MAKEDEV funcs.
- Other misc compatibility tweaks.

authenticate.c
clientserver.c
main.c
popt/system.h
rsync.h
testsuite/chown.test
testsuite/daemon.test
testsuite/devices.test
testsuite/rsync.fns

index 8fd6ff69b3d06365d645ce2ae99c8f50ad9e031c..4306d1672317521665c7debe05f2a1e4cd27ef06 100644 (file)
@@ -119,7 +119,7 @@ static const char *check_secret(int module, const char *user, const char *group,
                if ((st.st_mode & 06) != 0) {
                        rprintf(FLOG, "secrets file must not be other-accessible (see strict modes option)\n");
                        ok = 0;
-               } else if (MY_UID() == 0 && st.st_uid != 0) {
+               } else if (MY_UID() == ROOT_UID && st.st_uid != ROOT_UID) {
                        rprintf(FLOG, "secrets file must be owned by root when running as root (see strict modes)\n");
                        ok = 0;
                }
@@ -196,7 +196,7 @@ static const char *getpassf(const char *filename)
                        rprintf(FERROR, "ERROR: password file must not be other-accessible\n");
                        exit_cleanup(RERR_SYNTAX);
                }
-               if (MY_UID() == 0 && st.st_uid != 0) {
+               if (MY_UID() == ROOT_UID && st.st_uid != ROOT_UID) {
                        rprintf(FERROR, "ERROR: password file must be owned by root when running as root\n");
                        exit_cleanup(RERR_SYNTAX);
                }
index 831c3eab576ff525f7d3f8a989863d89d51a4263..372f9ab3eb3b2a505c3b6e1216e394fcda757b68 100644 (file)
@@ -704,7 +704,7 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
                logfile_format_has_o_or_i = 1;
 
        uid = MY_UID();
-       am_root = (uid == 0);
+       am_root = (uid == ROOT_UID);
 
        p = *lp_uid(module_id) ? lp_uid(module_id) : am_root ? NOBODY_USER : NULL;
        if (p) {
@@ -959,7 +959,7 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
                }
 
                our_uid = MY_UID();
-               am_root = (our_uid == 0);
+               am_root = (our_uid == ROOT_UID);
        }
 
        if (lp_temp_dir(module_id) && *lp_temp_dir(module_id)) {
@@ -1213,7 +1213,7 @@ int start_daemon(int f_in, int f_out)
                        return -1;
                }
                our_uid = MY_UID();
-               am_root = (our_uid == 0);
+               am_root = (our_uid == ROOT_UID);
        }
 
        addr = client_addr(f_in);
diff --git a/main.c b/main.c
index c832d575e8b31675e725dad0394af4956eee7e3c..ad30c86f7d1271e96cd9db7c125897d36a6d8fea 100644 (file)
--- a/main.c
+++ b/main.c
@@ -299,7 +299,7 @@ static void become_copy_as_user()
 
        our_uid = MY_UID();
        our_gid = MY_GID();
-       am_root = (our_uid == 0);
+       am_root = (our_uid == ROOT_UID);
 
        if (gname)
                gname[-1] = ':';
@@ -1667,7 +1667,7 @@ int main(int argc,char *argv[])
        starttime = time(NULL);
        our_uid = MY_UID();
        our_gid = MY_GID();
-       am_root = our_uid == 0;
+       am_root = our_uid == ROOT_UID;
 
        memset(&stats, 0, sizeof(stats));
 
index 50cecaf54e161852946b86e863c93127ff952eb3..25c22daeef3b1d889de3cb711ee4698755207234 100644 (file)
@@ -11,6 +11,10 @@ extern __const __int32_t *__ctype_toupper;
 /*@=declundef@*/
 #endif
 
+#ifdef __TANDEM
+# include <floss.h(floss_execvp,floss_read)>
+#endif
+
 #include <ctype.h>
 
 #include <errno.h>
diff --git a/rsync.h b/rsync.h
index 5983c906d452d7c7a3916e9023ca73838a25a3fc..957f3d3201c5a2547e62f9a7140275b4fdf19d92 100644 (file)
--- a/rsync.h
+++ b/rsync.h
@@ -473,7 +473,23 @@ enum delret {
 #ifdef MAKEDEV_TAKES_3_ARGS
 #define MAKEDEV(devmajor,devminor) makedev(0,devmajor,devminor)
 #else
+#ifndef __TANDEM
 #define MAKEDEV(devmajor,devminor) makedev(devmajor,devminor)
+#else
+# include <sys/stat.h>
+# define major DEV_TO_MAJOR
+# define minor DEV_TO_MINOR
+# define MAKEDEV MAJORMINOR_TO_DEV
+#endif
+#endif
+
+#ifdef __TANDEM
+# include <floss.h(floss_read,floss_write,floss_fork,floss_execvp)>
+# include <floss.h(floss_getpwuid,floss_select,floss_seteuid)>
+# define S_IEXEC S_IXUSR
+# define ROOT_UID 65535
+#else
+# define ROOT_UID 0
 #endif
 
 #ifdef HAVE_COMPAT_H
index aa4958d8de2de9f84e31a771fbfd392065ab2575..1464c65a80babe916fb28f71b29674bc439291f0 100644 (file)
@@ -48,15 +48,16 @@ EOF
     ;;
 *)
     RSYNC="$RSYNC --super"
-    case `get_testuid` in
-    '') ;; # If "id" failed, try to continue...
-    0)  ;;
-    *)  if [ -e "$FAKEROOT_PATH" ]; then
+    my_uid=`get_testuid`
+    root_uid=`get_rootuid`
+    if test x"$my_uid" = x; then
+       : # If "id" failed, try to continue...
+    elif test x"$my_uid" != x"$root_uid"; then
+       if [ -e "$FAKEROOT_PATH" ]; then
            echo "Let's try re-running the script under fakeroot..."
            exec "$FAKEROOT_PATH" "$SHELL_PATH" "$0"
        fi
-       ;;
-    esac
+    fi
     ;;
 esac
 
index a736ee83b9d129d1757939ce9ec4d55bf6106a07..836ce33be69587d28816669bd581677a6a5bc832 100644 (file)
@@ -41,14 +41,14 @@ cd "$scratchdir"
 
 ln -s test-rsyncd.conf rsyncd.conf
 
+my_uid=`get_testuid`
+root_uid=`get_rootuid`
 confopt=''
-case `get_testuid` in
-0)
+if test x"$my_uid" = x"$root_uid"; then
     # Root needs to specify the config file, or it uses /etc/rsyncd.conf.
     echo "Forcing --config=$conf"
     confopt=" --config=$conf"
-    ;;
-esac
+fi
 
 # These have a space-padded 15-char name, then a tab, then a comment.
 sed 's/NOCOMMENT//' <<EOT >"$chkfile"
index 0af0428bd0484aa8290628e9f043938227be3d64..908898c2abe75d87a31f19312614b6c49c749ed1 100644 (file)
@@ -67,16 +67,17 @@ EOF
     esac
     ;;
 *)
-    case `get_testuid` in
-    '') ;; # If "id" failed, try to continue...
-    0)  ;;
-    *)  if [ -e "$FAKEROOT_PATH" ]; then
+    my_uid=`get_testuid`
+    root_uid=`get_rootuid`
+    if test x"$my_uid" = x; then
+       : # If "id" failed, try to continue...
+    elif test x"$my_uid" != x"$root_uid"; then
+       if [ -e "$FAKEROOT_PATH" ]; then
            echo "Let's try re-running the script under fakeroot..."
            exec "$FAKEROOT_PATH" "$SHELL_PATH" $RUNSHFLAGS "$0"
        fi
        test_skipped "Rsync needs root/fakeroot for device tests"
-       ;;
-    esac
+    fi
     ;;
 esac
 
index 58701fd739401a88e91f584efabee43fb19aa9ed..023a8e196e05c259f65b1489b43a3c51195b4f0d 100644 (file)
@@ -102,7 +102,27 @@ rsync_ls_lR() {
 }
 
 get_testuid() {
-    id 2>/dev/null | sed 's/^[^0-9]*\([0-9][0-9]*\).*/\1/'
+    uid=`id -u 2>/dev/null`
+    case "$uid" in
+       [0-9]*) echo "$uid" ;;
+       *) id 2>/dev/null | sed 's/^[^0-9]*\([0-9][0-9]*\).*/\1/' ;;
+    esac
+}
+
+get_rootuid() {
+    uid=`id -u root 2>/dev/null`
+    case "$uid" in
+       [0-9]*) echo "$uid" ;;
+       *) echo 0 ;;
+    esac
+}
+
+get_rootgid() {
+    gid=`id -g root 2>/dev/null`
+    case "$gid" in
+       [0-9]*) echo "$gid" ;;
+       *) echo 0 ;;
+    esac
 }
 
 check_perms() {
@@ -278,16 +298,18 @@ build_rsyncd_conf() {
     logfile="$scratchdir/rsyncd.log"
     hostname=`uname -n`
 
-    uid_setting='uid = 0'
-    gid_setting='gid = 0'
-    case `get_testuid` in
-    0) ;;
-    *)
+    my_uid=`get_testuid`
+    root_uid=`get_rootuid`
+    root_gid=`get_rootgid`
+
+    uid_setting="uid = $root_uid"
+    gid_setting="gid = $root_gid"
+
+    if test x"$my_uid" != x"$root_uid"; then
        # Non-root cannot specify uid & gid settings
        uid_setting="#$uid_setting"
        gid_setting="#$gid_setting"
-       ;;
-    esac
+    fi
 
     cat >"$conf" <<EOF
 # rsyncd configuration file autogenerated by $0