ctdb-build: Remove duplicate socket_wrapper library
[Samba.git] / examples / libsmbclient / testacl2.c
bloba74a72d794c3fac235d567ac315457f32d158426
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];
28 SMBCCTX *context;
30 if (smbc_init(get_auth_data_fn, debug) != 0)
32 printf("Could not initialize smbc_ library\n");
33 return 1;
36 context = smbc_set_context(NULL);
37 smbc_setOptionFullTimeNames(context, 1);
39 the_acl = strdup("system.nt_sec_desc.*");
40 ret = smbc_getxattr(argv[1], the_acl, value, sizeof(value));
41 if (ret < 0)
43 printf("Could not get attributes for [%s] %d: %s\n",
44 argv[1], errno, strerror(errno));
45 return 1;
48 printf("Attributes for [%s] are:\n%s\n", argv[1], value);
50 flags = 0;
51 debugstr = "set attributes (1st time)";
53 ret = smbc_setxattr(argv[1], the_acl, value, strlen(value), flags);
54 if (ret < 0)
56 printf("Could not %s for [%s] %d: %s\n",
57 debugstr, argv[1], errno, strerror(errno));
58 return 1;
61 flags = 0;
62 debugstr = "set attributes (2nd time)";
64 ret = smbc_setxattr(argv[1], the_acl, value, strlen(value), flags);
65 if (ret < 0)
67 printf("Could not %s for [%s] %d: %s\n",
68 debugstr, argv[1], errno, strerror(errno));
69 return 1;
72 return 0;