diff options
author | Gerald Carter <jerry@samba.org> | 2007-05-21 21:17:21 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2007-05-21 21:17:21 +0000 |
commit | 34059e63c8a644b10cf9a59cca5e67a45053d16e (patch) | |
tree | b0751d47f93023938656df3c6173618dfef4f1e5 /examples | |
parent | c3f0e56c057f6be60bd3721485f013ed63defa6a (diff) | |
download | samba-34059e63c8a644b10cf9a59cca5e67a45053d16e.tar.gz |
r23052: sync with SAMBA_3_0_25 and start updating release notes
Diffstat (limited to 'examples')
-rw-r--r-- | examples/libsmbclient/Makefile | 5 | ||||
-rw-r--r-- | examples/libsmbclient/testacl2.c | 78 |
2 files changed, 83 insertions, 0 deletions
diff --git a/examples/libsmbclient/Makefile b/examples/libsmbclient/Makefile index ee117c9fe92..d44df77b3fb 100644 --- a/examples/libsmbclient/Makefile +++ b/examples/libsmbclient/Makefile @@ -17,6 +17,7 @@ LIBSMBCLIENT = ../../source/bin/libsmbclient.a -ldl -lresolv TESTS= testsmbc \ tree \ testacl \ + testacl2 \ testbrowse \ testbrowse2 \ teststat \ @@ -39,6 +40,10 @@ testacl: testacl.o @echo Linking testacl $(CC) `gtk-config --cflags` $(CFLAGS) $(LDFLAGS) -o $@ $< `gtk-config --libs` $(LIBSMBCLIENT) -lpopt +testacl2: testacl2.o + @echo Linking testacl2 + $(CC) `gtk-config --cflags` $(CFLAGS) $(LDFLAGS) -o $@ $< `gtk-config --libs` $(LIBSMBCLIENT) -lpopt + testbrowse: testbrowse.o @echo Linking testbrowse $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt diff --git a/examples/libsmbclient/testacl2.c b/examples/libsmbclient/testacl2.c new file mode 100644 index 00000000000..df38fe208ed --- /dev/null +++ b/examples/libsmbclient/testacl2.c @@ -0,0 +1,78 @@ +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <popt.h> +#include "libsmbclient.h" +#include "get_auth_data_fn.h" + +enum acl_mode +{ + SMB_ACL_GET, + SMB_ACL_SET, + SMB_ACL_DELETE, + SMB_ACL_MODIFY, + SMB_ACL_ADD, + SMB_ACL_CHOWN, + SMB_ACL_CHGRP +}; + + +int main(int argc, const char *argv[]) +{ + int i; + int opt; + int flags; + int debug = 0; + int numeric = 0; + int full_time_names = 0; + enum acl_mode mode = SMB_ACL_GET; + static char *the_acl = NULL; + int ret; + char *p; + char *debugstr; + char value[1024]; + + if (smbc_init(get_auth_data_fn, debug) != 0) + { + printf("Could not initialize smbc_ library\n"); + return 1; + } + + SMBCCTX *context = smbc_set_context(NULL); + smbc_option_set(context, "full_time_names", 1); + + the_acl = strdup("system.nt_sec_desc.*"); + ret = smbc_getxattr(argv[1], the_acl, value, sizeof(value)); + if (ret < 0) + { + printf("Could not get attributes for [%s] %d: %s\n", + argv[1], errno, strerror(errno)); + return 1; + } + + printf("Attributes for [%s] are:\n%s\n", argv[1], value); + + flags = 0; + debugstr = "set attributes (1st time)"; + + ret = smbc_setxattr(argv[1], the_acl, value, strlen(value), flags); + if (ret < 0) + { + printf("Could not %s for [%s] %d: %s\n", + debugstr, argv[1], errno, strerror(errno)); + return 1; + } + + flags = 0; + debugstr = "set attributes (2nd time)"; + + ret = smbc_setxattr(argv[1], the_acl, value, strlen(value), flags); + if (ret < 0) + { + printf("Could not %s for [%s] %d: %s\n", + debugstr, argv[1], errno, strerror(errno)); + return 1; + } + + return 0; +} |