root/source4/rpc_server/common/share_info.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. dcesrv_common_get_share_permissions
  2. dcesrv_common_get_share_current_users
  3. dcesrv_common_get_share_type
  4. dcesrv_common_get_share_path
  5. dcesrv_common_get_share_dfs_flags
  6. dcesrv_common_get_security_descriptor

   1 /* 
   2    Unix SMB/CIFS implementation.
   3 
   4    common share info functions
   5 
   6    Copyright (C) Stefan (metze) Metzmacher 2004
   7    
   8    This program is free software; you can redistribute it and/or modify
   9    it under the terms of the GNU General Public License as published by
  10    the Free Software Foundation; either version 3 of the License, or
  11    (at your option) any later version.
  12    
  13    This program is distributed in the hope that it will be useful,
  14    but WITHOUT ANY WARRANTY; without even the implied warranty of
  15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16    GNU General Public License for more details.
  17    
  18    You should have received a copy of the GNU General Public License
  19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  20 */
  21 
  22 #include "includes.h"
  23 #include "param/share.h"
  24 #include "librpc/gen_ndr/srvsvc.h"
  25 #include "rpc_server/dcerpc_server.h"
  26 #include "rpc_server/common/common.h"
  27 #include "rpc_server/common/proto.h"
  28 
  29 /* 
  30     Here are common server info functions used by some dcerpc server interfaces
  31 */
  32 
  33 /* This hardcoded value should go into a ldb database! */
  34 uint32_t dcesrv_common_get_share_permissions(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, struct share_config *scfg)
     /* [<][>][^][v][top][bottom][index][help] */
  35 {
  36         return 0;
  37 }
  38 
  39 /* This hardcoded value should go into a ldb database! */
  40 uint32_t dcesrv_common_get_share_current_users(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, struct share_config *scfg)
     /* [<][>][^][v][top][bottom][index][help] */
  41 {
  42         return 1;
  43 }
  44 
  45 /* This hardcoded value should go into a ldb database! */
  46 enum srvsvc_ShareType dcesrv_common_get_share_type(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, struct share_config *scfg)
     /* [<][>][^][v][top][bottom][index][help] */
  47 {
  48         /* for disk share       0x00000000
  49          * for print share      0x00000001
  50          * for IPC$ share       0x00000003 
  51          *
  52          * administrative shares:
  53          * ADMIN$, IPC$, C$, D$, E$ ...  are type |= 0x80000000
  54          * this ones are hidden in NetShareEnum, but shown in NetShareEnumAll
  55          */
  56         enum srvsvc_ShareType share_type = 0;
  57         const char *sharetype;
  58 
  59         if (!share_bool_option(scfg, SHARE_BROWSEABLE, SHARE_BROWSEABLE_DEFAULT)) {
  60                 share_type |= STYPE_HIDDEN;
  61         }
  62 
  63         sharetype = share_string_option(scfg, SHARE_TYPE, SHARE_TYPE_DEFAULT);
  64         if (sharetype && strcasecmp(sharetype, "IPC") == 0) {
  65                 share_type |= STYPE_IPC;
  66                 return share_type;
  67         }
  68 
  69         if (sharetype && strcasecmp(sharetype, "PRINTER") == 0) {
  70                 share_type |= STYPE_PRINTQ;
  71                 return share_type;
  72         }
  73 
  74         share_type |= STYPE_DISKTREE;
  75 
  76         return share_type;
  77 }
  78 
  79 /* This hardcoded value should go into a ldb database! */
  80 const char *dcesrv_common_get_share_path(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, struct share_config *scfg)
     /* [<][>][^][v][top][bottom][index][help] */
  81 {
  82         const char *sharetype;
  83         char *p;
  84         
  85         sharetype = share_string_option(scfg, SHARE_TYPE, SHARE_TYPE_DEFAULT);
  86         
  87         if (sharetype && strcasecmp(sharetype, "IPC") == 0) {
  88                 return talloc_strdup(mem_ctx, "");
  89         }
  90 
  91         p = talloc_strdup(mem_ctx, share_string_option(scfg, SHARE_PATH, ""));
  92         if (!p) {
  93                 return NULL;
  94         }
  95         if (p[0] == '\0') {
  96                 return p;
  97         }
  98         all_string_sub(p, "/", "\\", 0);
  99         
 100         return talloc_asprintf(mem_ctx, "C:%s", p);
 101 }
 102 
 103 /* This hardcoded value should go into a ldb database! */
 104 uint32_t dcesrv_common_get_share_dfs_flags(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, struct share_config *scfg)
     /* [<][>][^][v][top][bottom][index][help] */
 105 {
 106         return 0;
 107 }
 108 
 109 /* This hardcoded value should go into a ldb database! */
 110 struct security_descriptor *dcesrv_common_get_security_descriptor(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, struct share_config *scfg)
     /* [<][>][^][v][top][bottom][index][help] */
 111 {
 112         return NULL;
 113 }

/* [<][>][^][v][top][bottom][index][help] */