diff options
author | Pierre Humblet <phumblet@phumblet.no-ip.org> | 2003-03-01 19:38:26 +0300 |
---|---|---|
committer | Pierre Humblet <phumblet@phumblet.no-ip.org> | 2003-03-01 19:38:26 +0300 |
commit | f78765daddab38eb37fb9ee28960bac930b47754 (patch) | |
tree | eab595e60ce6716c312e3df8b0c1ad77c1e366c5 /winsup/utils/mkpasswd.c | |
parent | 5a082e9eac4c97b8ef669f43788c40f733da1646 (diff) |
2003-03-01 Pierre Humblet <pierre.humblet@ieee.org>
* mkpasswd.cc (main): On Win95, output both a default line and a
line for the current user (if known) with a pseudorandom uid. If
the -u switch is given, produce a line for the specified user.
* mkgroup.cc (main): On Win95 change the group name from "unknown" to
"all".
Diffstat (limited to 'winsup/utils/mkpasswd.c')
-rw-r--r-- | winsup/utils/mkpasswd.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/winsup/utils/mkpasswd.c b/winsup/utils/mkpasswd.c index 3e54bd42c..3158490a5 100644 --- a/winsup/utils/mkpasswd.c +++ b/winsup/utils/mkpasswd.c @@ -632,24 +632,34 @@ main (int argc, char **argv) if (!isNT) { /* This takes Windows 9x/ME into account. */ + if (passed_home_path[0] == '\0') + strcpy (passed_home_path, "/home/"); if (!disp_username) { + printf ("admin:use_crypt:%lu:%lu:Administrator:%sadmin:/bin/bash\n", + DOMAIN_USER_RID_ADMIN, + DOMAIN_ALIAS_RID_ADMINS, + passed_home_path); if (GetUserName (name, (len = 256, &len))) disp_username = name; - else - /* Same behaviour as in cygwin/shared.cc (memory_init). */ - disp_username = (char *) "unknown"; } - - if (passed_home_path[0] == '\0') - strcpy (passed_home_path, "/home/"); - - printf ("%s:*:%ld:%ld:%s:%s%s:/bin/bash\n", disp_username, - DOMAIN_USER_RID_ADMIN, - DOMAIN_ALIAS_RID_ADMINS, - disp_username, - passed_home_path, - disp_username); + if (disp_username && disp_username[0]) + { + /* Create a pseudo random uid */ + unsigned long uid = 0, i; + for (i = 0; disp_username[i]; i++) + uid += toupper (disp_username[i]) << ((6 * i) % 25); + uid = (uid % (65535 - DOMAIN_USER_RID_ADMIN - 1)) + + DOMAIN_USER_RID_ADMIN + 1; + + printf ("%s:use_crypt:%lu:%lu:%s:%s%s:/bin/bash\n", + disp_username, + uid, + DOMAIN_ALIAS_RID_ADMINS, + disp_username, + passed_home_path, + disp_username); + } return 0; } if (!print_local && !print_domain && !print_local_groups) |