r18412: Implement NetiNameValidate but just for share name right now (type 9)
authorSimo Sorce <idra@samba.org>
Tue, 12 Sep 2006 02:24:21 +0000 (02:24 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:18:25 +0000 (14:18 -0500)
Simo.
(This used to be commit 906429834a102349582017ef73a69e211ef5c500)

source4/rpc_server/common/server_info.c
source4/rpc_server/srvsvc/dcesrv_srvsvc.c

index cd8106c03a9e970e1339fe7e0c7561055a8215a7..12f5c90e8dfcc0a9ecad4a0f201e1ecb4570ce7d 100644 (file)
@@ -132,4 +132,13 @@ _PUBLIC_ const char *dcesrv_common_get_userpath(TALLOC_CTX *mem_ctx, struct dces
        return talloc_strdup(mem_ctx, "c:\\");
 }
 
+#define INVALID_SHARE_NAME_CHARS " \"*+,./:;<=>?[\\]|"
 
+_PUBLIC_ bool dcesrv_common_validate_share_name(TALLOC_CTX *mem_ctx, const char *share_name)
+{
+       if (strpbrk(share_name, INVALID_SHARE_NAME_CHARS)) {
+               return False;
+       }
+
+       return True;
+}
index d850af5ebd12bab7e9517b93b5fde9c321fef05c..2464da447afb92349daaaec0ebeecc5b910c52da 100644 (file)
@@ -1273,7 +1273,47 @@ static WERROR srvsvc_NetPathCompare(struct dcesrv_call_state *dce_call, TALLOC_C
 static WERROR srvsvc_NetNameValidate(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct srvsvc_NetNameValidate *r)
 {
-       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+       int len;
+
+       if ((r->in.flags != 0x0) && (r->in.flags != 0x80000000)) {
+               return WERR_INVALID_NAME;
+       }
+
+       switch (r->in.name_type) {
+       case 1:
+       case 2:
+       case 3:
+       case 4:
+       case 5:
+       case 6:
+       case 7:
+       case 8:
+               return WERR_NOT_SUPPORTED;
+
+       case 9: /* validate share name */
+
+               len = strlen_m(r->in.name);
+               if ((r->in.flags == 0x0) && (len > 81)) {
+                       return WERR_INVALID_NAME;
+               }
+               if ((r->in.flags == 0x80000000) && (len > 13)) {
+                       return WERR_INVALID_NAME;
+               }
+               if (! dcesrv_common_validate_share_name(mem_ctx, r->in.name)) {
+                       return WERR_INVALID_NAME;
+               }
+               return WERR_OK;
+
+       case 10:
+       case 11:
+       case 12:
+       case 13:
+               return WERR_NOT_SUPPORTED;
+       default:
+               return WERR_INVALID_PARAM;
+       }
+
+       return WERR_INVALID_PARAM;
 }