Index: samba-3.0.25b/source/client/mount.cifs.c =================================================================== --- samba-3.0.25b.orig/source/client/mount.cifs.c 2007-07-11 19:54:30.000000000 -0700 +++ samba-3.0.25b/source/client/mount.cifs.c 2007-07-11 20:17:40.000000000 -0700 @@ -321,6 +321,8 @@ int out_len = 0; int word_len; int rc = 0; + char user[32]; + char group[32]; if (!optionsp || !*optionsp) return 1; @@ -331,6 +333,13 @@ /* BB fixme check for separator override BB */ + if (getuid()) { + got_uid = 1; + sprintf(user,"%u",getuid()); + got_gid = 1; + sprintf(group,"%u",getgid()); + } + /* while ((data = strsep(&options, ",")) != NULL) { */ while(data != NULL) { /* check if ends with trailing comma */ @@ -493,33 +502,35 @@ got_uid = 1; if (!isdigit(*value)) { struct passwd *pw; - static char temp[32]; if (!(pw = getpwnam(value))) { printf("bad user name \"%s\"\n", value); exit(1); } - sprintf(temp, "%u", pw->pw_uid); - value = temp; + sprintf(user, "%u", pw->pw_uid); endpwent(); + } else { + strcpy(user,value); } } + goto nocopy; } else if (strncmp(data, "gid", 3) == 0) { if (value && *value) { got_gid = 1; if (!isdigit(*value)) { struct group *gr; - static char temp[32]; if (!(gr = getgrnam(value))) { printf("bad group name \"%s\"\n", value); exit(1); } - sprintf(temp, "%u", gr->gr_gid); - value = temp; + sprintf(group, "%u", gr->gr_gid); endpwent(); + } else { + strcpy(group,value); } } + goto nocopy; /* fmask and dmask synonyms for people used to smbfs syntax */ } else if (strcmp(data, "file_mode") == 0 || strcmp(data, "fmask")==0) { if (!value || !*value) { @@ -621,6 +632,37 @@ nocopy: data = next_keyword; } + + // special-case the uid and gid + if (got_uid) { + word_len = strlen(user); + + out = (char *)realloc(out, out_len + word_len + 6); + if (out == NULL) { + perror("malloc"); + exit(1); + } + + if (out_len) + out[out_len++] = ','; + sprintf(out + out_len, "uid=%s", user); + out_len = strlen(out); + } + if (got_gid) { + word_len = strlen(group); + + out = (char *)realloc(out, out_len + word_len + 6); + if (out == NULL) { + perror("malloc"); + exit(1); + } + + if (out_len) + out[out_len++] = ','; + sprintf(out + out_len, "gid=%s", group); + out_len = strlen(out); + } + free(*optionsp); *optionsp = out; return 0;