Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

testacl2.c

Go to the documentation of this file.
00001 #include <stdlib.h>
00002 #include <string.h>
00003 #include <errno.h>
00004 #include <popt.h>
00005 #include "libsmbclient.h"
00006 #include "get_auth_data_fn.h"
00007 
00008 enum acl_mode
00009 {
00010     SMB_ACL_GET,
00011     SMB_ACL_SET,
00012     SMB_ACL_DELETE,
00013     SMB_ACL_MODIFY,
00014     SMB_ACL_ADD,
00015     SMB_ACL_CHOWN,
00016     SMB_ACL_CHGRP
00017 };
00018 
00019 
00020 int main(int argc, const char *argv[])
00021 {
00022     int i;
00023     int opt;
00024     int flags;
00025     int debug = 0;
00026     int numeric = 0;
00027     int full_time_names = 0;
00028     enum acl_mode mode = SMB_ACL_GET;
00029     static char *the_acl = NULL;
00030     int ret;
00031     char *p;
00032     char *debugstr;
00033     char value[1024];
00034 
00035     if (smbc_init(get_auth_data_fn, debug) != 0)
00036     {
00037         printf("Could not initialize smbc_ library\n");
00038         return 1;
00039     }
00040 
00041     SMBCCTX *context = smbc_set_context(NULL);
00042     smbc_option_set(context, "full_time_names", 1);
00043     
00044     the_acl = strdup("system.nt_sec_desc.*");
00045     ret = smbc_getxattr(argv[1], the_acl, value, sizeof(value));
00046     if (ret < 0)
00047     {
00048         printf("Could not get attributes for [%s] %d: %s\n",
00049                argv[1], errno, strerror(errno));
00050         return 1;
00051     }
00052     
00053     printf("Attributes for [%s] are:\n%s\n", argv[1], value);
00054 
00055     flags = 0;
00056     debugstr = "set attributes (1st time)";
00057         
00058     ret = smbc_setxattr(argv[1], the_acl, value, strlen(value), flags);
00059     if (ret < 0)
00060     {
00061         printf("Could not %s for [%s] %d: %s\n",
00062                debugstr, argv[1], errno, strerror(errno));
00063         return 1;
00064     }
00065     
00066     flags = 0;
00067     debugstr = "set attributes (2nd time)";
00068         
00069     ret = smbc_setxattr(argv[1], the_acl, value, strlen(value), flags);
00070     if (ret < 0)
00071     {
00072         printf("Could not %s for [%s] %d: %s\n",
00073                debugstr, argv[1], errno, strerror(errno));
00074         return 1;
00075     }
00076     
00077     return 0;
00078 }

© sourcejam.com 2005-2008