char *ace_type_to_str(uint ace_type)
{
- fstring temp;
+ static fstring temp;
switch(ace_type) {
case SEC_ACE_TYPE_ACCESS_DENIED:
char *ace_mask_to_str(uint32 ace_mask)
{
- fstring temp;
+ static fstring temp;
switch (ace_mask) {
case PRINTER_ACE_FULL_CONTROL:
char *ace_to_str(SEC_ACE *ace)
{
- pstring temp;
+ static pstring temp;
fstring sidstr;
sid_to_string(sidstr, &ace->sid);
return temp;
}
-int str_to_ace(SEC_ACE *ace, char *ace_str)
+void str_to_ace(SEC_ACE *ace, char *ace_str)
{
SEC_ACCESS sa;
DOM_SID sid;
prs_struct ps;
int result = 0, i;
+ ZERO_STRUCT(ps);
+
/* Open tdb for reading */
- slprintf(tdb_path, "%s/ntdrivers.tdb", LOCKDIR);
+ slprintf(tdb_path, sizeof(tdb_path) - 1, "%s/ntdrivers.tdb",
+ lp_lockdir());
+
tdb = tdb_open(tdb_path, 0, 0, O_RDONLY, 0600);
if (!tdb) {
if (tdb_prs_fetch(tdb, keystr, &ps, mem_ctx) != 0) {
printf("error fetching descriptor for printer %s\n",
printer);
- result = 1;
- goto done;
+ /* cannot do a prs_mem_free() when tdb_prs_fetch fails */
+ /* as the prs structure has not been initialized */
+ tdb_close(tdb);
+ talloc_destroy(mem_ctx);
+ return 1;
}
/* Unpack into security descriptor buffer */
for (i = 0; i < secdesc_ctr->sec->dacl->num_aces; i++) {
SEC_ACE *ace = &secdesc_ctr->sec->dacl->ace[i];
- fstring sidstr;
sid_to_string(sidstr, &ace->sid);
if (tdb) tdb_close(tdb);
if (mem_ctx) talloc_destroy(mem_ctx);
if (secdesc_ctr) free_sec_desc_buf(&secdesc_ctr);
+ prs_mem_free(&ps);
return result;
}
{
DOM_SID user_sid, group_sid;
SEC_ACE *ace_list = NULL;
- SEC_ACL *dacl;
+ SEC_ACL *dacl = NULL;
SEC_DESC *sd;
SEC_DESC_BUF *sdb = NULL;
int result = 0, num_aces = 0;
TALLOC_CTX *mem_ctx = NULL;
BOOL has_user_sid = False, has_group_sid = False;
+ ZERO_STRUCT(ps);
+
/* Open tdb for reading */
- slprintf(tdb_path, "%s/ntdrivers.tdb", LOCKDIR);
+ slprintf(tdb_path, sizeof(tdb_path) - 1, "%s/ntdrivers.tdb",
+ lp_lockdir());
+
tdb = tdb_open(tdb_path, 0, 0, O_RDWR, 0600);
if (!tdb) {
/* Create security descriptor */
- sd = make_sec_desc(SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE |
- SEC_DESC_DACL_PRESENT,
+ sd = make_sec_desc(SEC_DESC_REVISION,
has_user_sid ? &user_sid : NULL,
has_group_sid ? &group_sid : NULL,
NULL, /* System ACL */
dacl, /* Discretionary ACL */
&size);
+ free_sec_acl(&dacl);
+
sdb = make_sec_desc_buf(size, sd);
free_sec_desc(&sd);
if (tdb) tdb_close(tdb);
if (sdb) free_sec_desc_buf(&sdb);
if (mem_ctx) talloc_destroy(mem_ctx);
+ prs_mem_free(&ps);
return result;
}
int main(int argc, char **argv)
{
+ pstring servicesf = CONFIGFILE;
+
/* Argument check */
if (argc == 1) {
return 1;
}
+ /* Load smb.conf file */
+
+ charset_initialise();
+
+ if (!lp_load(servicesf,False,False,True)) {
+ fprintf(stderr, "Couldn't load confiuration file %s\n",
+ servicesf);
+ return 1;
+ }
+
/* Do commands */
if (strcmp(argv[1], "setsec") == 0) {