91024056597a8f22d1fa4e1c34476a5154f8edfa
[samba.git] / examples / libsmbclient / testacl3.c
1 #include <sys/types.h>
2 #include <stdio.h> 
3 #include <unistd.h>
4 #include <string.h> 
5 #include <time.h> 
6 #include <errno.h>
7 #include <libsmbclient.h> 
8 #include "get_auth_data_fn.h"
9
10
11 int main(int argc, char * argv[]) 
12
13     int             i;
14     int             fd;
15     int             ret;
16     int             debug = 0;
17     int             mode = 0666;
18     int             savedErrno;
19     char            value[2048]; 
20     char            path[2048];
21     char *          the_acl;
22     char *          p;
23     time_t          t0;
24     time_t          t1;
25     struct stat     st; 
26     SMBCCTX *       context;
27     
28     smbc_init(get_auth_data_fn, debug); 
29     
30     context = smbc_set_context(NULL);
31     smbc_option_set(context, "full_time_names", 1);
32     
33     for (;;)
34     {
35         fprintf(stdout, "Path: ");
36         *path = '\0';
37         fgets(path, sizeof(path) - 1, stdin);
38         if (strlen(path) == 0)
39         {
40             return 0;
41         }
42
43         p = path + strlen(path) - 1;
44         if (*p == '\n')
45         {
46             *p = '\0';
47         }
48     
49         the_acl = strdup("system.nt_sec_desc.*+");
50         ret = smbc_getxattr(path, the_acl, value, sizeof(value));
51         if (ret < 0)
52         {
53             printf("Could not get attributes for [%s] %d: %s\n",
54                    path, errno, strerror(errno));
55             return 1;
56         }
57     
58         printf("Attributes for [%s] are:\n%s\n", path, value);
59     }
60
61     return 0; 
62 }