| 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" | 
|---|
| 7 |  | 
|---|
| 8 | enum acl_mode | 
|---|
| 9 | { | 
|---|
| 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 | 
|---|
| 17 | }; | 
|---|
| 18 |  | 
|---|
| 19 |  | 
|---|
| 20 | int main(int argc, const char *argv[]) | 
|---|
| 21 | { | 
|---|
| 22 | int i; | 
|---|
| 23 | int opt; | 
|---|
| 24 | int flags; | 
|---|
| 25 | int debug = 0; | 
|---|
| 26 | int numeric = 0; | 
|---|
| 27 | int full_time_names = 0; | 
|---|
| 28 | enum acl_mode mode = SMB_ACL_GET; | 
|---|
| 29 | static char *the_acl = NULL; | 
|---|
| 30 | int ret; | 
|---|
| 31 | char *p; | 
|---|
| 32 | char *debugstr; | 
|---|
| 33 | char value[1024]; | 
|---|
| 34 |  | 
|---|
| 35 | if (smbc_init(get_auth_data_fn, debug) != 0) | 
|---|
| 36 | { | 
|---|
| 37 | printf("Could not initialize smbc_ library\n"); | 
|---|
| 38 | return 1; | 
|---|
| 39 | } | 
|---|
| 40 |  | 
|---|
| 41 | SMBCCTX *context = smbc_set_context(NULL); | 
|---|
| 42 | smbc_setOptionFullTimeNames(context, 1); | 
|---|
| 43 |  | 
|---|
| 44 | the_acl = strdup("system.nt_sec_desc.*"); | 
|---|
| 45 | ret = smbc_getxattr(argv[1], the_acl, value, sizeof(value)); | 
|---|
| 46 | if (ret < 0) | 
|---|
| 47 | { | 
|---|
| 48 | printf("Could not get attributes for [%s] %d: %s\n", | 
|---|
| 49 | argv[1], errno, strerror(errno)); | 
|---|
| 50 | return 1; | 
|---|
| 51 | } | 
|---|
| 52 |  | 
|---|
| 53 | printf("Attributes for [%s] are:\n%s\n", argv[1], value); | 
|---|
| 54 |  | 
|---|
| 55 | flags = 0; | 
|---|
| 56 | debugstr = "set attributes (1st time)"; | 
|---|
| 57 |  | 
|---|
| 58 | ret = smbc_setxattr(argv[1], the_acl, value, strlen(value), flags); | 
|---|
| 59 | if (ret < 0) | 
|---|
| 60 | { | 
|---|
| 61 | printf("Could not %s for [%s] %d: %s\n", | 
|---|
| 62 | debugstr, argv[1], errno, strerror(errno)); | 
|---|
| 63 | return 1; | 
|---|
| 64 | } | 
|---|
| 65 |  | 
|---|
| 66 | flags = 0; | 
|---|
| 67 | debugstr = "set attributes (2nd time)"; | 
|---|
| 68 |  | 
|---|
| 69 | ret = smbc_setxattr(argv[1], the_acl, value, strlen(value), flags); | 
|---|
| 70 | if (ret < 0) | 
|---|
| 71 | { | 
|---|
| 72 | printf("Could not %s for [%s] %d: %s\n", | 
|---|
| 73 | debugstr, argv[1], errno, strerror(errno)); | 
|---|
| 74 | return 1; | 
|---|
| 75 | } | 
|---|
| 76 |  | 
|---|
| 77 | return 0; | 
|---|
| 78 | } | 
|---|