Skip to content

Commit 59cb358

Browse files
committed
More TANDEM changes
- Handle a non-0 root uid. - Handle alternate major/minor/MAKEDEV funcs. - Other misc compatibility tweaks.
1 parent bb16db1 commit 59cb358

9 files changed

+75
-31
lines changed

authenticate.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ static const char *check_secret(int module, const char *user, const char *group,
119119
if ((st.st_mode & 06) != 0) {
120120
rprintf(FLOG, "secrets file must not be other-accessible (see strict modes option)\n");
121121
ok = 0;
122-
} else if (MY_UID() == 0 && st.st_uid != 0) {
122+
} else if (MY_UID() == ROOT_UID && st.st_uid != ROOT_UID) {
123123
rprintf(FLOG, "secrets file must be owned by root when running as root (see strict modes)\n");
124124
ok = 0;
125125
}
@@ -196,7 +196,7 @@ static const char *getpassf(const char *filename)
196196
rprintf(FERROR, "ERROR: password file must not be other-accessible\n");
197197
exit_cleanup(RERR_SYNTAX);
198198
}
199-
if (MY_UID() == 0 && st.st_uid != 0) {
199+
if (MY_UID() == ROOT_UID && st.st_uid != ROOT_UID) {
200200
rprintf(FERROR, "ERROR: password file must be owned by root when running as root\n");
201201
exit_cleanup(RERR_SYNTAX);
202202
}

clientserver.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
704704
logfile_format_has_o_or_i = 1;
705705

706706
uid = MY_UID();
707-
am_root = (uid == 0);
707+
am_root = (uid == ROOT_UID);
708708

709709
p = *lp_uid(module_id) ? lp_uid(module_id) : am_root ? NOBODY_USER : NULL;
710710
if (p) {
@@ -959,7 +959,7 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
959959
}
960960

961961
our_uid = MY_UID();
962-
am_root = (our_uid == 0);
962+
am_root = (our_uid == ROOT_UID);
963963
}
964964

965965
if (lp_temp_dir(module_id) && *lp_temp_dir(module_id)) {
@@ -1213,7 +1213,7 @@ int start_daemon(int f_in, int f_out)
12131213
return -1;
12141214
}
12151215
our_uid = MY_UID();
1216-
am_root = (our_uid == 0);
1216+
am_root = (our_uid == ROOT_UID);
12171217
}
12181218

12191219
addr = client_addr(f_in);

main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ static void become_copy_as_user()
299299

300300
our_uid = MY_UID();
301301
our_gid = MY_GID();
302-
am_root = (our_uid == 0);
302+
am_root = (our_uid == ROOT_UID);
303303

304304
if (gname)
305305
gname[-1] = ':';
@@ -1667,7 +1667,7 @@ int main(int argc,char *argv[])
16671667
starttime = time(NULL);
16681668
our_uid = MY_UID();
16691669
our_gid = MY_GID();
1670-
am_root = our_uid == 0;
1670+
am_root = our_uid == ROOT_UID;
16711671

16721672
memset(&stats, 0, sizeof(stats));
16731673

popt/system.h

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ extern __const __int32_t *__ctype_toupper;
1111
/*@=declundef@*/
1212
#endif
1313

14+
#ifdef __TANDEM
15+
# include <floss.h(floss_execvp,floss_read)>
16+
#endif
17+
1418
#include <ctype.h>
1519

1620
#include <errno.h>

rsync.h

+16
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,23 @@ enum delret {
473473
#ifdef MAKEDEV_TAKES_3_ARGS
474474
#define MAKEDEV(devmajor,devminor) makedev(0,devmajor,devminor)
475475
#else
476+
#ifndef __TANDEM
476477
#define MAKEDEV(devmajor,devminor) makedev(devmajor,devminor)
478+
#else
479+
# include <sys/stat.h>
480+
# define major DEV_TO_MAJOR
481+
# define minor DEV_TO_MINOR
482+
# define MAKEDEV MAJORMINOR_TO_DEV
483+
#endif
484+
#endif
485+
486+
#ifdef __TANDEM
487+
# include <floss.h(floss_read,floss_write,floss_fork,floss_execvp)>
488+
# include <floss.h(floss_getpwuid,floss_select,floss_seteuid)>
489+
# define S_IEXEC S_IXUSR
490+
# define ROOT_UID 65535
491+
#else
492+
# define ROOT_UID 0
477493
#endif
478494

479495
#ifdef HAVE_COMPAT_H

testsuite/chown.test

+7-6
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,16 @@ EOF
4848
;;
4949
*)
5050
RSYNC="$RSYNC --super"
51-
case `get_testuid` in
52-
'') ;; # If "id" failed, try to continue...
53-
0) ;;
54-
*) if [ -e "$FAKEROOT_PATH" ]; then
51+
my_uid=`get_testuid`
52+
root_uid=`get_rootuid`
53+
if test x"$my_uid" = x; then
54+
: # If "id" failed, try to continue...
55+
elif test x"$my_uid" != x"$root_uid"; then
56+
if [ -e "$FAKEROOT_PATH" ]; then
5557
echo "Let's try re-running the script under fakeroot..."
5658
exec "$FAKEROOT_PATH" "$SHELL_PATH" "$0"
5759
fi
58-
;;
59-
esac
60+
fi
6061
;;
6162
esac
6263

testsuite/daemon.test

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ cd "$scratchdir"
4141

4242
ln -s test-rsyncd.conf rsyncd.conf
4343

44+
my_uid=`get_testuid`
45+
root_uid=`get_rootuid`
4446
confopt=''
45-
case `get_testuid` in
46-
0)
47+
if test x"$my_uid" = x"$root_uid"; then
4748
# Root needs to specify the config file, or it uses /etc/rsyncd.conf.
4849
echo "Forcing --config=$conf"
4950
confopt=" --config=$conf"
50-
;;
51-
esac
51+
fi
5252

5353
# These have a space-padded 15-char name, then a tab, then a comment.
5454
sed 's/NOCOMMENT//' <<EOT >"$chkfile"

testsuite/devices.test

+7-6
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,17 @@ EOF
6767
esac
6868
;;
6969
*)
70-
case `get_testuid` in
71-
'') ;; # If "id" failed, try to continue...
72-
0) ;;
73-
*) if [ -e "$FAKEROOT_PATH" ]; then
70+
my_uid=`get_testuid`
71+
root_uid=`get_rootuid`
72+
if test x"$my_uid" = x; then
73+
: # If "id" failed, try to continue...
74+
elif test x"$my_uid" != x"$root_uid"; then
75+
if [ -e "$FAKEROOT_PATH" ]; then
7476
echo "Let's try re-running the script under fakeroot..."
7577
exec "$FAKEROOT_PATH" "$SHELL_PATH" $RUNSHFLAGS "$0"
7678
fi
7779
test_skipped "Rsync needs root/fakeroot for device tests"
78-
;;
79-
esac
80+
fi
8081
;;
8182
esac
8283

testsuite/rsync.fns

+30-8
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,27 @@ rsync_ls_lR() {
102102
}
103103

104104
get_testuid() {
105-
id 2>/dev/null | sed 's/^[^0-9]*\([0-9][0-9]*\).*/\1/'
105+
uid=`id -u 2>/dev/null`
106+
case "$uid" in
107+
[0-9]*) echo "$uid" ;;
108+
*) id 2>/dev/null | sed 's/^[^0-9]*\([0-9][0-9]*\).*/\1/' ;;
109+
esac
110+
}
111+
112+
get_rootuid() {
113+
uid=`id -u root 2>/dev/null`
114+
case "$uid" in
115+
[0-9]*) echo "$uid" ;;
116+
*) echo 0 ;;
117+
esac
118+
}
119+
120+
get_rootgid() {
121+
gid=`id -g root 2>/dev/null`
122+
case "$gid" in
123+
[0-9]*) echo "$gid" ;;
124+
*) echo 0 ;;
125+
esac
106126
}
107127

108128
check_perms() {
@@ -278,16 +298,18 @@ build_rsyncd_conf() {
278298
logfile="$scratchdir/rsyncd.log"
279299
hostname=`uname -n`
280300

281-
uid_setting='uid = 0'
282-
gid_setting='gid = 0'
283-
case `get_testuid` in
284-
0) ;;
285-
*)
301+
my_uid=`get_testuid`
302+
root_uid=`get_rootuid`
303+
root_gid=`get_rootgid`
304+
305+
uid_setting="uid = $root_uid"
306+
gid_setting="gid = $root_gid"
307+
308+
if test x"$my_uid" != x"$root_uid"; then
286309
# Non-root cannot specify uid & gid settings
287310
uid_setting="#$uid_setting"
288311
gid_setting="#$gid_setting"
289-
;;
290-
esac
312+
fi
291313

292314
cat >"$conf" <<EOF
293315
# rsyncd configuration file autogenerated by $0

0 commit comments

Comments
 (0)