- Handle a non-0 root uid.
- Handle alternate major/minor/MAKEDEV funcs.
- Other misc compatibility tweaks.
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;
}
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);
}
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) {
}
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)) {
return -1;
}
our_uid = MY_UID();
- am_root = (our_uid == 0);
+ am_root = (our_uid == ROOT_UID);
}
addr = client_addr(f_in);
our_uid = MY_UID();
our_gid = MY_GID();
- am_root = (our_uid == 0);
+ am_root = (our_uid == ROOT_UID);
if (gname)
gname[-1] = ':';
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));
/*@=declundef@*/
#endif
+#ifdef __TANDEM
+# include <floss.h(floss_execvp,floss_read)>
+#endif
+
#include <ctype.h>
#include <errno.h>
#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
;;
*)
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
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"
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
}
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() {
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