aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2001-04-15 14:09:33 +0000
committerCorinna Vinschen <corinna@vinschen.de>2001-04-15 14:09:33 +0000
commit9f2cad57a65757981675decc852e9b14f86026b2 (patch)
tree194e22faa22a58e45a59803f79f5172387b74e94
parent1ff87985a175ff56e9e813b2dbdfa856dec5ca35 (diff)
downloadnewlib-9f2cad57a65757981675decc852e9b14f86026b2.zip
newlib-9f2cad57a65757981675decc852e9b14f86026b2.tar.gz
newlib-9f2cad57a65757981675decc852e9b14f86026b2.tar.bz2
Patch by Kazuhiro Fujieda <fujieda@jaist.ac.jp>:
* mkgroup.c (enum_groups): Use RID + offset specified an additional argument as ID. (usage): Add description of -o option. (longopts, opts): Add specifications of -o/--id-offset option. (main): Add -o option. Invoke enum_groups with specified offset. * mkpasswd.c (enum_users): Just like mkgroup.c. (usage, longopts, opts): Ditto. (main): Add -o option. Invoke enum_users with specified offset only against domain accounts.
-rw-r--r--winsup/utils/ChangeLog12
-rw-r--r--winsup/utils/mkgroup.c29
-rw-r--r--winsup/utils/mkpasswd.c19
3 files changed, 44 insertions, 16 deletions
diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog
index 4d71998..a3327ea 100644
--- a/winsup/utils/ChangeLog
+++ b/winsup/utils/ChangeLog
@@ -1,3 +1,15 @@
+2001-04-13 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
+
+ * mkgroup.c (enum_groups): Use RID + offset specified an additional
+ argument as ID.
+ (usage): Add description of -o option.
+ (longopts, opts): Add specifications of -o/--id-offset option.
+ (main): Add -o option. Invoke enum_groups with specified offset.
+ * mkpasswd.c (enum_users): Just like mkgroup.c.
+ (usage, longopts, opts): Ditto.
+ (main): Add -o option. Invoke enum_users with specified offset
+ only against domain accounts.
+
2001-04-11 Egor Duda <deo@logos-m.ru>
* mkgroup.c (uni2ansi): Use native method to convert from Unicode
diff --git a/winsup/utils/mkgroup.c b/winsup/utils/mkgroup.c
index 331788f..801d12a 100644
--- a/winsup/utils/mkgroup.c
+++ b/winsup/utils/mkgroup.c
@@ -187,7 +187,7 @@ enum_local_groups (int print_sids)
}
void
-enum_groups (LPWSTR servername, int print_sids)
+enum_groups (LPWSTR servername, int print_sids, int id_offset)
{
GROUP_INFO_2 *buffer;
DWORD entriesread = 0;
@@ -273,7 +273,7 @@ enum_groups (LPWSTR servername, int print_sids)
}
printf ("%s:%s:%d:\n", groupname,
print_sids ? put_sid (psid) : "",
- gid);
+ gid + id_offset);
}
netapibufferfree (buffer);
@@ -291,13 +291,15 @@ usage ()
fprintf (stderr, "Usage: mkgroup [OPTION]... [domain]\n\n");
fprintf (stderr, "This program prints a /etc/group file to stdout\n\n");
fprintf (stderr, "Options:\n");
- fprintf (stderr, " -l,--local print local group information\n");
- fprintf (stderr, " -d,--domain print global group information from the domain\n");
- fprintf (stderr, " specified (or from the current domain if there is\n");
- fprintf (stderr, " no domain specified)\n");
- fprintf (stderr, " -s,--no-sids don't print SIDs in pwd field\n");
- fprintf (stderr, " (this affects ntsec)\n");
- fprintf (stderr, " -?,--help print this message\n\n");
+ fprintf (stderr, " -l,--local print local group information\n");
+ fprintf (stderr, " -d,--domain print global group information from the domain\n");
+ fprintf (stderr, " specified (or from the current domain if there is\n");
+ fprintf (stderr, " no domain specified)\n");
+ fprintf (stderr, " -o,--id-offset offset change the default offset (10000) added to uids\n");
+ fprintf (stderr, " in domain accounts.\n");
+ fprintf (stderr, " -s,--no-sids don't print SIDs in pwd field\n");
+ fprintf (stderr, " (this affects ntsec)\n");
+ fprintf (stderr, " -?,--help print this message\n\n");
fprintf (stderr, "One of `-l' or `-d' must be given on NT/W2K.\n");
return 1;
}
@@ -305,12 +307,13 @@ usage ()
struct option longopts[] = {
{"local", no_argument, NULL, 'l'},
{"domain", no_argument, NULL, 'd'},
+ {"id-offset", required_argument, NULL, 'o'},
{"no-sids", no_argument, NULL, 's'},
{"help", no_argument, NULL, 'h'},
{0, no_argument, NULL, 0}
};
-char opts[] = "ldsh";
+char opts[] = "ldo:sh";
int
main (int argc, char **argv)
@@ -322,6 +325,7 @@ main (int argc, char **argv)
int print_domain = 0;
int print_sids = 1;
int domain_specified = 0;
+ int id_offset = 10000;
int i;
char name[256], dom[256];
@@ -343,6 +347,9 @@ main (int argc, char **argv)
case 'd':
print_domain = 1;
break;
+ case 'o':
+ id_offset = strtol (optarg, NULL, 10);
+ break;
case 's':
print_sids = 0;
break;
@@ -464,7 +471,7 @@ main (int argc, char **argv)
exit (1);
}
- enum_groups (servername, print_sids);
+ enum_groups (servername, print_sids, id_offset);
}
if (print_local)
diff --git a/winsup/utils/mkpasswd.c b/winsup/utils/mkpasswd.c
index 1309cac..d81db1a 100644
--- a/winsup/utils/mkpasswd.c
+++ b/winsup/utils/mkpasswd.c
@@ -102,7 +102,7 @@ uni2ansi (LPWSTR wcs, char *mbs, int size)
int
enum_users (LPWSTR servername, int print_sids, int print_cygpath,
- const char * passed_home_path)
+ const char * passed_home_path, int id_offset)
{
USER_INFO_3 *buffer;
DWORD entriesread = 0;
@@ -205,7 +205,9 @@ enum_users (LPWSTR servername, int print_sids, int print_cygpath,
}
}
}
- printf ("%s::%d:%d:%s%s%s:%s:/bin/sh\n", username, uid, gid,
+ printf ("%s::%d:%d:%s%s%s:%s:/bin/sh\n", username,
+ uid + id_offset,
+ gid + id_offset,
fullname,
print_sids ? "," : "",
print_sids ? put_sid (psid) : "",
@@ -318,6 +320,8 @@ usage ()
fprintf (stderr, " -l,--local print local user accounts\n");
fprintf (stderr, " -d,--domain print domain accounts (from current domain\n");
fprintf (stderr, " if no domain specified)\n");
+ fprintf (stderr, " -o,--id-offset offset change the default offset (10000) added to uids\n");
+ fprintf (stderr, " in domain accounts.\n");
fprintf (stderr, " -g,--local-groups print local group information too\n");
fprintf (stderr, " if no domain specified\n");
fprintf (stderr, " -m,--no-mount don't use mount points for home dir\n");
@@ -333,6 +337,7 @@ usage ()
struct option longopts[] = {
{"local", no_argument, NULL, 'l'},
{"domain", no_argument, NULL, 'd'},
+ {"id-offset", required_argument, NULL, 'o'},
{"local-groups", no_argument, NULL, 'g'},
{"no-mount", no_argument, NULL, 'm'},
{"no-sids", no_argument, NULL, 's'},
@@ -341,7 +346,7 @@ struct option longopts[] = {
{0, no_argument, NULL, 0}
};
-char opts[] = "ldgsmhp:";
+char opts[] = "ldo:gsmhp:";
int
main (int argc, char **argv)
@@ -355,6 +360,7 @@ main (int argc, char **argv)
int domain_name_specified = 0;
int print_sids = 1;
int print_cygpath = 1;
+ int id_offset = 10000;
int i;
char name[256], dom[256], passed_home_path[MAX_PATH];
@@ -378,6 +384,9 @@ main (int argc, char **argv)
case 'd':
print_domain = 1;
break;
+ case 'o':
+ id_offset = strtol (optarg, NULL, 10);
+ break;
case 'g':
print_local_groups = 1;
break;
@@ -522,11 +531,11 @@ main (int argc, char **argv)
exit (1);
}
- enum_users (servername, print_sids, print_cygpath, passed_home_path);
+ enum_users (servername, print_sids, print_cygpath, passed_home_path, id_offset);
}
if (print_local)
- enum_users (NULL, print_sids, print_cygpath, passed_home_path);
+ enum_users (NULL, print_sids, print_cygpath, passed_home_path, 0);
if (servername)
netapibufferfree (servername);