s4:torture: add a test-suite for VSS
[bbaumbach/samba-autobuild/.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             ret;
14     int             debug = 0;
15     char            value[2048]; 
16     char            path[2048];
17     char *          the_acl;
18     char *          p;
19     SMBCCTX *       context;
20     
21     smbc_init(get_auth_data_fn, debug); 
22     
23     context = smbc_set_context(NULL);
24     smbc_setOptionFullTimeNames(context, 1);
25     
26     for (;;)
27     {
28         fprintf(stdout, "Path: ");
29         *path = '\0';
30         p = fgets(path, sizeof(path) - 1, stdin);
31         if (p == NULL) {
32                 printf("Error reading from stdin\n");
33                 return 1;
34         }
35         if (strlen(path) == 0)
36         {
37             return 0;
38         }
39
40         p = path + strlen(path) - 1;
41         if (*p == '\n')
42         {
43             *p = '\0';
44         }
45     
46         the_acl = strdup("system.nt_sec_desc.*+");
47         ret = smbc_getxattr(path, the_acl, value, sizeof(value));
48         if (ret < 0)
49         {
50             printf("Could not get attributes for [%s] %d: %s\n",
51                    path, errno, strerror(errno));
52             return 1;
53         }
54     
55         printf("Attributes for [%s] are:\n%s\n", path, value);
56     }
57
58     return 0; 
59 }