summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-03-26 02:14:40 +0000
committerJeremy Allison <jra@samba.org>1998-03-26 02:14:40 +0000
commit0601a41993d6ea4fb2a186b7ca55b2f3a6f6a53d (patch)
tree9e504cd86bc83473c2e4a2a6e8d403dbf609f211
parentf6bf7baebe4dc0813627c4d34b36820dccae94b2 (diff)
downloadsamba-0601a41993d6ea4fb2a186b7ca55b2f3a6f6a53d.tar.gz
samba-0601a41993d6ea4fb2a186b7ca55b2f3a6f6a53d.tar.xz
samba-0601a41993d6ea4fb2a186b7ca55b2f3a6f6a53d.zip
smbpass.c: Made unknown accounts ending in '$' server accounts, not
workstation. smbpasswd.c: Added code to count down from last machine account to add correct uid when adding a machine account. Jeremy.
-rw-r--r--source/passdb/smbpass.c2
-rw-r--r--source/utils/smbpasswd.c34
2 files changed, 30 insertions, 6 deletions
diff --git a/source/passdb/smbpass.c b/source/passdb/smbpass.c
index 0c5c2902992..b481a501e6a 100644
--- a/source/passdb/smbpass.c
+++ b/source/passdb/smbpass.c
@@ -417,7 +417,7 @@ struct smb_passwd *getsmbpwent(FILE *fp)
*/
if(pw_buf.smb_name[strlen(pw_buf.smb_name) - 1] == '$') {
pw_buf.acct_ctrl &= ~ACB_NORMAL;
- pw_buf.acct_ctrl |= ACB_WSTRUST;
+ pw_buf.acct_ctrl |= ACB_SVRTRUST;
}
}
diff --git a/source/utils/smbpasswd.c b/source/utils/smbpasswd.c
index db7f4c12e2e..3a81a987187 100644
--- a/source/utils/smbpasswd.c
+++ b/source/utils/smbpasswd.c
@@ -359,9 +359,27 @@ char *encode_acct_ctrl(uint16 acct_ctrl)
machine account.
***********************************************************/
-int get_machine_uid(void)
+int get_new_machine_uid(void)
{
- return 65534;
+ int next_uid_start;
+ FILE *fp;
+ struct smb_passwd *smbpw;
+
+ if(sizeof(uid_t) == 2)
+ next_uid_start = 65533;
+
+ if(sizeof(uid_t) == 4)
+ next_uid_start = 0x7fffffff;
+
+ fp = startsmbpwent(False);
+ while((smbpw = getsmbpwent(fp)) != NULL) {
+ if(!(smbpw->acct_ctrl & ACB_SVRTRUST))
+ continue;
+
+ next_uid_start = MIN(next_uid_start, (smbpw->smb_userid-1));
+ }
+ endsmbpwent(fp);
+ return next_uid_start;
}
/*********************************************************
@@ -372,7 +390,7 @@ static void usage(char *name, BOOL is_root)
{
if(is_root)
fprintf(stderr, "Usage is : %s [-a] [-d] [-m] [-n] [username] [password]\n\
-%s: [-r machine] [username] [password]\n%s: [-h]\n", name, name, name);
+%s: [-R <name resolve order>] [-r machine] [username] [password]\n%s: [-h]\n", name, name, name);
else
fprintf(stderr, "Usage is : %s [-h] [-r machine] [password]\n", name);
exit(1);
@@ -450,7 +468,7 @@ int main(int argc, char **argv)
is_root = (real_uid == 0);
- while ((ch = getopt(argc, argv, "adhmnr:")) != EOF) {
+ while ((ch = getopt(argc, argv, "adhmnr:R:")) != EOF) {
switch(ch) {
case 'a':
if(is_root)
@@ -476,6 +494,12 @@ int main(int argc, char **argv)
case 'r':
remote_machine = optarg;
break;
+ case 'R':
+ if(is_root) {
+ lp_set_name_resolve_order(optarg);
+ break;
+ } else
+ usage(prog_name, is_root);
case 'm':
if(is_root)
machine_account = True;
@@ -714,7 +738,7 @@ int main(int argc, char **argv)
pwd->pw_gecos = "";
pwd->pw_dir = machine_dir_name;
pwd->pw_shell = "";
- pwd->pw_uid = get_machine_uid();
+ pwd->pw_uid = get_new_machine_uid();
}