|
Last change
on this file since 988 was 988, checked in by Silvan Scherrer, 9 years ago |
|
Samba Server: update vendor to version 4.4.3
|
|
File size:
1.2 KB
|
| Rev | Line | |
|---|
| [414] | 1 | #include <stdio.h>
|
|---|
| 2 | #include <unistd.h>
|
|---|
| 3 | #include <string.h>
|
|---|
| 4 | #include <time.h>
|
|---|
| 5 | #include <libsmbclient.h>
|
|---|
| 6 | #include "get_auth_data_fn.h"
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 | int main(int argc, char * argv[])
|
|---|
| 10 | {
|
|---|
| 11 | int debug = 0;
|
|---|
| 12 | int mode = 0666;
|
|---|
| [988] | 13 | const char * pSmbPath = NULL;
|
|---|
| [414] | 14 | struct stat st;
|
|---|
| 15 |
|
|---|
| 16 | if (argc == 1)
|
|---|
| 17 | {
|
|---|
| 18 | pSmbPath = "smb://RANDOM/Public/small";
|
|---|
| 19 | }
|
|---|
| 20 | else if (argc == 2)
|
|---|
| 21 | {
|
|---|
| 22 | pSmbPath = argv[1];
|
|---|
| 23 | }
|
|---|
| 24 | else if (argc == 3)
|
|---|
| 25 | {
|
|---|
| 26 | pSmbPath = argv[1];
|
|---|
| 27 | mode = (int) strtol(argv[2], NULL, 8);
|
|---|
| 28 | }
|
|---|
| 29 | else
|
|---|
| 30 | {
|
|---|
| 31 | printf("usage: "
|
|---|
| 32 | "%s [ smb://path/to/file [ octal_mode ] ]\n",
|
|---|
| 33 | argv[0]);
|
|---|
| 34 | return 1;
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | smbc_init(get_auth_data_fn, debug);
|
|---|
| 38 |
|
|---|
| 39 | if (smbc_stat(pSmbPath, &st) < 0)
|
|---|
| 40 | {
|
|---|
| 41 | perror("smbc_stat");
|
|---|
| 42 | return 1;
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| [988] | 45 | printf("\nBefore chmod: mode = %04o\n", (unsigned int)st.st_mode);
|
|---|
| [414] | 46 |
|
|---|
| 47 | if (smbc_chmod(pSmbPath, mode) < 0)
|
|---|
| 48 | {
|
|---|
| 49 | perror("smbc_chmod");
|
|---|
| 50 | return 1;
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | if (smbc_stat(pSmbPath, &st) < 0)
|
|---|
| 54 | {
|
|---|
| 55 | perror("smbc_stat");
|
|---|
| 56 | return 1;
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| [988] | 59 | printf("After chmod: mode = %04o\n", (unsigned int)st.st_mode);
|
|---|
| [414] | 60 |
|
|---|
| 61 | return 0;
|
|---|
| 62 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.