summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-10-12 05:33:05 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:49 -0500
commit4962d9d03efd91bf4e7209cff47877f20d7de25d (patch)
tree986ee9e7543626ba38ba1b61069801aedb4fe7d5
parent52f525c104ae2d17901f104cbf482395dc803cc1 (diff)
downloadsamba-4962d9d03efd91bf4e7209cff47877f20d7de25d.tar.gz
samba-4962d9d03efd91bf4e7209cff47877f20d7de25d.tar.bz2
samba-4962d9d03efd91bf4e7209cff47877f20d7de25d.zip
r2928: - fixed the handling of reserved names (rejecting them with ACCESS_DENIED)
- don't check for '.' specially in checking for legal names. Longhorn doesn't do this any more, and its a real pain. Longhorn allows for filenames ending in '.', and with as many '.' elements as you like. (This used to be commit 0a475175c53016bfa5b8246819676ddcd8b66feb)
-rw-r--r--source4/ntvfs/posix/pvfs_resolve.c3
-rw-r--r--source4/ntvfs/posix/pvfs_shortname.c56
-rw-r--r--source4/ntvfs/posix/vfs_posix.h2
3 files changed, 23 insertions, 38 deletions
diff --git a/source4/ntvfs/posix/pvfs_resolve.c b/source4/ntvfs/posix/pvfs_resolve.c
index 5b1a5680ae..01f6b13ec2 100644
--- a/source4/ntvfs/posix/pvfs_resolve.c
+++ b/source4/ntvfs/posix/pvfs_resolve.c
@@ -84,6 +84,9 @@ static NTSTATUS pvfs_case_search(struct pvfs_state *pvfs, struct pvfs_filename *
components[i] = p;
p = strchr(p, '/');
if (p) *p++ = 0;
+ if (pvfs_is_reserved_name(pvfs, components[i])) {
+ return NT_STATUS_ACCESS_DENIED;
+ }
}
partial_name = talloc_strdup(name, components[0]);
diff --git a/source4/ntvfs/posix/pvfs_shortname.c b/source4/ntvfs/posix/pvfs_shortname.c
index 818c285fbc..c3c33fbc98 100644
--- a/source4/ntvfs/posix/pvfs_shortname.c
+++ b/source4/ntvfs/posix/pvfs_shortname.c
@@ -93,6 +93,10 @@
#define FLAG_CHECK(c, flag) (ctx->char_flags[(uint8_t)(c)] & (flag))
+static const char *reserved_names[] =
+{ "AUX", "CON", "COM1", "COM2", "COM3", "COM4",
+ "LPT1", "LPT2", "LPT3", "NUL", "PRN", NULL };
+
/*
hash a string of the specified length. The string does not need to be
@@ -367,11 +371,8 @@ static BOOL is_reserved_name(struct pvfs_mangle_context *ctx, const char *name)
FLAG_CHECK(name[3], FLAG_POSSIBLE4)) {
/* a likely match, scan the lot */
int i;
- for (i=0; ctx->reserved_names[i]; i++) {
- int len = strlen(ctx->reserved_names[i]);
- /* note that we match on COM1 as well as COM1.foo */
- if (strncasecmp(name, ctx->reserved_names[i], len) == 0 &&
- (name[len] == '.' || name[len] == 0)) {
+ for (i=0; reserved_names[i]; i++) {
+ if (strcasecmp(name, reserved_names[i]) == 0) {
return True;
}
}
@@ -387,10 +388,6 @@ static BOOL is_reserved_name(struct pvfs_mangle_context *ctx, const char *name)
*/
static BOOL is_legal_name(struct pvfs_mangle_context *ctx, const char *name)
{
- const char *dot_pos = NULL;
- BOOL alldots = True;
- size_t numdots = 0;
-
while (*name) {
size_t c_size;
codepoint_t c = next_codepoint(name, &c_size);
@@ -405,25 +402,9 @@ static BOOL is_legal_name(struct pvfs_mangle_context *ctx, const char *name)
if (FLAG_CHECK(c, FLAG_ILLEGAL)) {
return False;
}
- if (name[0] == '.') {
- dot_pos = name;
- numdots++;
- } else {
- alldots = False;
- }
-
name += c_size;
}
- if (dot_pos) {
- if (alldots && (numdots == 1 || numdots == 2))
- return True; /* . or .. is a valid name */
-
- /* A valid long name cannot end in '.' */
- if (dot_pos[1] == '\0')
- return False;
- }
-
return True;
}
@@ -567,10 +548,6 @@ static void init_tables(struct pvfs_mangle_context *ctx)
const char *basechars = MANGLE_BASECHARS;
int i;
/* the list of reserved dos names - all of these are illegal */
- const char *reserved_names[] =
- { "AUX", "LOCK$", "CON", "COM1", "COM2", "COM3", "COM4",
- "LPT1", "LPT2", "LPT3", "NUL", "PRN", NULL };
-
ZERO_STRUCT(ctx->char_flags);
@@ -598,17 +575,15 @@ static void init_tables(struct pvfs_mangle_context *ctx)
ctx->base_reverse[(uint8_t)basechars[i]] = i;
}
- ctx->reserved_names = reserved_names;
-
/* fill in the reserved names flags. These are used as a very
fast filter for finding possible DOS reserved filenames */
- for (i=0; ctx->reserved_names[i]; i++) {
+ for (i=0; reserved_names[i]; i++) {
unsigned char c1, c2, c3, c4;
- c1 = (unsigned char)ctx->reserved_names[i][0];
- c2 = (unsigned char)ctx->reserved_names[i][1];
- c3 = (unsigned char)ctx->reserved_names[i][2];
- c4 = (unsigned char)ctx->reserved_names[i][3];
+ c1 = (unsigned char)reserved_names[i][0];
+ c2 = (unsigned char)reserved_names[i][1];
+ c3 = (unsigned char)reserved_names[i][2];
+ c4 = (unsigned char)reserved_names[i][3];
ctx->char_flags[c1] |= FLAG_POSSIBLE1;
ctx->char_flags[c2] |= FLAG_POSSIBLE2;
@@ -702,3 +677,12 @@ char *pvfs_mangled_lookup(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
}
return NULL;
}
+
+
+/*
+ look for a DOS reserved name
+*/
+BOOL pvfs_is_reserved_name(struct pvfs_state *pvfs, const char *name)
+{
+ return is_reserved_name(pvfs->mangle_ctx, name);
+}
diff --git a/source4/ntvfs/posix/vfs_posix.h b/source4/ntvfs/posix/vfs_posix.h
index f6faf718be..38e55fd887 100644
--- a/source4/ntvfs/posix/vfs_posix.h
+++ b/source4/ntvfs/posix/vfs_posix.h
@@ -138,8 +138,6 @@ struct pvfs_mangle_context {
/* this is used to reverse the base 36 mapping */
unsigned char base_reverse[256];
-
- const char **reserved_names;
};