char *talloc_sub_specified(TALLOC_CTX *mem_ctx,
const char *input_string,
const char *username,
+ const char *grpname,
const char *domain,
uid_t uid,
gid_t gid);
char *talloc_sub_specified(TALLOC_CTX *mem_ctx,
const char *input_string,
const char *username,
+ const char *grpname,
const char *domain,
uid_t uid,
gid_t gid)
break;
case 'G' :
if (gid != -1) {
- a_string = talloc_string_sub(
- tmp_ctx, a_string, "%G",
- gidtoname(gid));
+ const char *name;
+
+ if (grpname != NULL) {
+ name = grpname;
+ } else {
+ name = gidtoname(gid);
+ }
+
+ a_string = talloc_string_sub(tmp_ctx,
+ a_string,
+ "%G",
+ name);
} else {
a_string = talloc_string_sub(
tmp_ctx, a_string,
break;
case 'g' :
if (gid != -1) {
- a_string = talloc_string_sub(
- tmp_ctx, a_string, "%g",
- gidtoname(gid));
+ const char *name;
+
+ if (grpname != NULL) {
+ name = grpname;
+ } else {
+ name = gidtoname(gid);
+ }
+
+ a_string = talloc_string_sub(tmp_ctx,
+ a_string,
+ "%g",
+ name);
} else {
a_string = talloc_string_sub(
tmp_ctx, a_string, "%g", "NO_GROUP");
/* set some basic attributes */
pdb_set_profile_path(user, talloc_sub_specified(user,
- lp_logon_path(), pwd->pw_name, domain, pwd->pw_uid, pwd->pw_gid),
+ lp_logon_path(), pwd->pw_name, NULL, domain, pwd->pw_uid, pwd->pw_gid),
PDB_DEFAULT);
pdb_set_homedir(user, talloc_sub_specified(user,
- lp_logon_home(), pwd->pw_name, domain, pwd->pw_uid, pwd->pw_gid),
+ lp_logon_home(), pwd->pw_name, NULL, domain, pwd->pw_uid, pwd->pw_gid),
PDB_DEFAULT);
pdb_set_dir_drive(user, talloc_sub_specified(user,
- lp_logon_drive(), pwd->pw_name, domain, pwd->pw_uid, pwd->pw_gid),
+ lp_logon_drive(), pwd->pw_name, NULL, domain, pwd->pw_uid, pwd->pw_gid),
PDB_DEFAULT);
pdb_set_logon_script(user, talloc_sub_specified(user,
- lp_logon_script(), pwd->pw_name, domain, pwd->pw_uid, pwd->pw_gid),
+ lp_logon_script(), pwd->pw_name, NULL, domain, pwd->pw_uid, pwd->pw_gid),
PDB_DEFAULT);
}
if (is_machine) {
/* TODO: choose a more appropriate default for machines */
- homedir = talloc_sub_specified(tmp_ctx, lp_template_homedir(), "SMB_workstations_home", ldap_state->domain_name, uid, gid);
+ homedir = talloc_sub_specified(tmp_ctx,
+ lp_template_homedir(),
+ "SMB_workstations_home",
+ NULL,
+ ldap_state->domain_name,
+ uid,
+ gid);
shell = talloc_strdup(tmp_ctx, "/bin/false");
} else {
- homedir = talloc_sub_specified(tmp_ctx, lp_template_homedir(), name, ldap_state->domain_name, uid, gid);
- shell = talloc_sub_specified(tmp_ctx, lp_template_shell(), name, ldap_state->domain_name, uid, gid);
+ homedir = talloc_sub_specified(tmp_ctx,
+ lp_template_homedir(),
+ name,
+ NULL,
+ ldap_state->domain_name,
+ uid,
+ gid);
+ shell = talloc_sub_specified(tmp_ctx,
+ lp_template_shell(),
+ name,
+ NULL,
+ ldap_state->domain_name,
+ uid,
+ gid);
}
uidstr = talloc_asprintf(tmp_ctx, "%u", (unsigned int)uid);
gidstr = talloc_asprintf(tmp_ctx, "%u", (unsigned int)gid);
char *subst;
bool result = true;
- subst = talloc_sub_specified(talloc_tos(), str, user, domain, uid, gid);
+ subst = talloc_sub_specified(talloc_tos(), str, user, NULL, domain, uid, gid);
if (strcmp(subst, expected) != 0) {
printf("sub_specified(%s, %s, %s, %d, %d) returned [%s], expected "
gidstr = talloc_asprintf(tc, "%u", (unsigned int)domadmins_gid);
dir = talloc_sub_specified(tc, lp_template_homedir(),
"Administrator",
+ NULL,
get_global_sam_name(),
uid, domadmins_gid);
shell = talloc_sub_specified(tc, lp_template_shell(),
"Administrator",
+ NULL,
get_global_sam_name(),
uid, domadmins_gid);
if ((in != NULL) && (in[0] != '\0') && (lp_security() == SEC_ADS)) {
templ = talloc_sub_specified(talloc_tos(), in,
- username, domname,
+ username, NULL, domname,
uid, gid);
} else {
templ = talloc_sub_specified(talloc_tos(), lp_template,
- username, domname,
+ username, NULL, domname,
uid, gid);
}