dsdb-acl: introduce a 'el' helper variable to acl_modify()
[Samba/gebeck_regimport.git] / examples / libsmbclient / testacl2.c
blobef044f8a8dcaff0459b8a84fd8a3bf802f6c8179
1 #include <stdlib.h>
2 #include <string.h>
3 #include <errno.h>
4 #include <popt.h>
5 #include "libsmbclient.h"
6 #include "get_auth_data_fn.h"
8 enum acl_mode
10 SMB_ACL_GET,
11 SMB_ACL_SET,
12 SMB_ACL_DELETE,
13 SMB_ACL_MODIFY,
14 SMB_ACL_ADD,
15 SMB_ACL_CHOWN,
16 SMB_ACL_CHGRP
20 int main(int argc, const char *argv[])
22 int flags;
23 int debug = 0;
24 static char *the_acl = NULL;
25 int ret;
26 const char *debugstr;
27 char value[1024];
29 if (smbc_init(get_auth_data_fn, debug) != 0)
31 printf("Could not initialize smbc_ library\n");
32 return 1;
35 SMBCCTX *context = smbc_set_context(NULL);
36 smbc_setOptionFullTimeNames(context, 1);
38 the_acl = strdup("system.nt_sec_desc.*");
39 ret = smbc_getxattr(argv[1], the_acl, value, sizeof(value));
40 if (ret < 0)
42 printf("Could not get attributes for [%s] %d: %s\n",
43 argv[1], errno, strerror(errno));
44 return 1;
47 printf("Attributes for [%s] are:\n%s\n", argv[1], value);
49 flags = 0;
50 debugstr = "set attributes (1st time)";
52 ret = smbc_setxattr(argv[1], the_acl, value, strlen(value), flags);
53 if (ret < 0)
55 printf("Could not %s for [%s] %d: %s\n",
56 debugstr, argv[1], errno, strerror(errno));
57 return 1;
60 flags = 0;
61 debugstr = "set attributes (2nd time)";
63 ret = smbc_setxattr(argv[1], the_acl, value, strlen(value), flags);
64 if (ret < 0)
66 printf("Could not %s for [%s] %d: %s\n",
67 debugstr, argv[1], errno, strerror(errno));
68 return 1;
71 return 0;