summaryrefslogtreecommitdiff
path: root/source3/utils/smbcacls.c
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2000-12-21 05:28:39 +0000
committerTim Potter <tpot@samba.org>2000-12-21 05:28:39 +0000
commit855bcea38e1c6264dced36c85fa949210f9c37a4 (patch)
treea1eed53e783379420ca825b4b4760e24ed49dfc8 /source3/utils/smbcacls.c
parent8fd4d9fab4195dcfcd13c455c3c2da665cbe8533 (diff)
downloadsamba-855bcea38e1c6264dced36c85fa949210f9c37a4.tar.gz
samba-855bcea38e1c6264dced36c85fa949210f9c37a4.tar.bz2
samba-855bcea38e1c6264dced36c85fa949210f9c37a4.zip
Some systems seem to only accept a ntcreate&x with a unicode filename
despite samba negotiating ascii filenames. Retry with unicode pathnames if the ascii version fails. Convert all forward slashes to backslashes in the filename argument. (This used to be commit 935b77573ec82bece6211a9f61c800ef1c8c9aa4)
Diffstat (limited to 'source3/utils/smbcacls.c')
-rw-r--r--source3/utils/smbcacls.c50
1 files changed, 45 insertions, 5 deletions
diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c
index bff80e7e5f..d73699264f 100644
--- a/source3/utils/smbcacls.c
+++ b/source3/utils/smbcacls.c
@@ -436,6 +436,29 @@ static void sec_desc_print(FILE *f, SEC_DESC *sd)
}
+/* Some systems seem to require unicode pathnames for the ntcreate&x call
+ despite Samba negotiating ascii filenames. Try with unicode pathname if
+ the ascii version fails. */
+
+int do_cli_nt_create(struct cli_state *cli, char *fname, uint32 DesiredAccess)
+{
+ int result;
+
+ result = cli_nt_create(cli, fname, DesiredAccess);
+
+ if (result == -1) {
+ uint32 errnum, nt_rpc_error;
+ uint8 errclass;
+
+ cli_error(cli, &errclass, &errnum, &nt_rpc_error);
+
+ if (errclass == ERRDOS && errnum == ERRbadpath) {
+ result = cli_nt_create_uni(cli, fname, DesiredAccess);
+ }
+ }
+
+ return result;
+}
/*****************************************************
dump the acls for a file
@@ -447,7 +470,7 @@ static void cacl_dump(struct cli_state *cli, char *filename)
if (test_args) return;
- fnum = cli_nt_create(cli, filename, 0x20000);
+ fnum = do_cli_nt_create(cli, filename, 0x20000);
if (fnum == -1) {
printf("Failed to open %s: %s\n", filename, cli_errstr(cli));
return;
@@ -479,7 +502,10 @@ static void owner_set(struct cli_state *cli, enum chown_mode change_mode, char *
SEC_DESC *sd, *old;
size_t sd_size;
- fnum = cli_nt_create(cli, filename, READ_CONTROL_ACCESS|WRITE_DAC_ACCESS|WRITE_OWNER_ACCESS);
+ fnum = do_cli_nt_create(cli, filename,
+ READ_CONTROL_ACCESS | WRITE_DAC_ACCESS
+ | WRITE_OWNER_ACCESS);
+
if (fnum == -1) {
printf("Failed to open %s: %s\n", filename, cli_errstr(cli));
return;
@@ -521,9 +547,12 @@ static void cacl_set(struct cli_state *cli, char *filename,
if (!sd) return;
if (test_args) return;
- /* the desired access below is the only one I could find that works with
- NT4, W2KP and Samba */
- fnum = cli_nt_create(cli, filename, MAXIMUM_ALLOWED_ACCESS | 0x60000);
+ /* The desired access below is the only one I could find that works
+ with NT4, W2KP and Samba */
+
+ fnum = do_cli_nt_create(cli, filename,
+ MAXIMUM_ALLOWED_ACCESS | 0x60000);
+
if (fnum == -1) {
printf("Failed to open %s: %s\n", filename, cli_errstr(cli));
return;
@@ -861,6 +890,17 @@ You can string acls together with spaces, commas or newlines\n\
if (!cli) exit(1);
}
+
+ {
+ char *s;
+
+ s = filename;
+ while(*s) {
+ if (*s == '/') *s = '\\';
+ s++;
+ }
+ }
+
/* Perform requested action */
if (change_mode != REQUEST_NONE) {