- p = lp_gid(i);
- if (!name_to_gid(p, &gid)) {
- if (!isdigit(*p)) {
- rprintf(FERROR,"Invalid gid %s\n", p);
- io_printf(fd,"@ERROR: invalid gid\n");
- return -1;
- }
- gid = atoi(p);
+ am_root = (MY_UID() == 0);
+
+ if (am_root) {
+ p = lp_uid(i);
+ if (!name_to_uid(p, &uid)) {
+ if (!isdigit(*(unsigned char *)p)) {
+ rprintf(FLOG, "Invalid uid %s\n", p);
+ io_printf(f_out, "@ERROR: invalid uid %s\n", p);
+ return -1;
+ }
+ uid = atoi(p);
+ }
+
+ p = lp_gid(i);
+ if (!name_to_gid(p, &gid)) {
+ if (!isdigit(*(unsigned char *)p)) {
+ rprintf(FLOG, "Invalid gid %s\n", p);
+ io_printf(f_out, "@ERROR: invalid gid %s\n", p);
+ return -1;
+ }
+ gid = atoi(p);
+ }
+ }
+
+ /* TODO: If we're not root, but the configuration requests
+ * that we change to some uid other than the current one, then
+ * log a warning. */
+
+ /* TODO: Perhaps take a list of gids, and make them into the
+ * supplementary groups. */
+
+ if (use_chroot) {
+ module_dirlen = 0;
+ set_filter_dir("/", 1);
+ } else {
+ module_dirlen = strlen(lp_path(i));
+ set_filter_dir(lp_path(i), module_dirlen);