LCOV - code coverage report
Current view: top level - source4/rpc_server/common - share_info.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 34 43 79.1 %
Date: 2024-04-21 15:09:00 Functions: 6 6 100.0 %

          Line data    Source code
       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/share.h"
      27             : 
      28             : #undef strcasecmp
      29             : 
      30             : /* 
      31             :     Here are common server info functions used by some dcerpc server interfaces
      32             : */
      33             : 
      34             : /* This hardcoded value should go into a ldb database! */
      35         234 : uint32_t dcesrv_common_get_share_permissions(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, struct share_config *scfg)
      36             : {
      37         234 :         return 0;
      38             : }
      39             : 
      40             : /* This hardcoded value should go into a ldb database! */
      41         234 : uint32_t dcesrv_common_get_share_current_users(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, struct share_config *scfg)
      42             : {
      43         234 :         return 1;
      44             : }
      45             : 
      46             : /* This hardcoded value should go into a ldb database! */
      47         774 : enum srvsvc_ShareType dcesrv_common_get_share_type(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, struct share_config *scfg)
      48             : {
      49             :         /* for disk share       0x00000000
      50             :          * for print share      0x00000001
      51             :          * for IPC$ share       0x00000003 
      52             :          *
      53             :          * administrative shares:
      54             :          * ADMIN$, IPC$, C$, D$, E$ ...  are type |= 0x80000000
      55             :          * this ones are hidden in NetShareEnum, but shown in NetShareEnumAll
      56             :          */
      57         774 :         enum srvsvc_ShareType share_type = 0;
      58           0 :         char *sharetype;
      59             : 
      60         774 :         if (!share_bool_option(scfg, SHARE_BROWSEABLE, SHARE_BROWSEABLE_DEFAULT)) {
      61          66 :                 share_type |= STYPE_HIDDEN;
      62             :         }
      63             : 
      64         774 :         sharetype = share_string_option(mem_ctx, scfg, SHARE_TYPE, SHARE_TYPE_DEFAULT);
      65         774 :         if (sharetype && strcasecmp(sharetype, "IPC") == 0) {
      66          66 :                 share_type |= STYPE_IPC;
      67          66 :                 TALLOC_FREE(sharetype);
      68          66 :                 return share_type;
      69             :         }
      70             : 
      71         708 :         if (sharetype && strcasecmp(sharetype, "PRINTER") == 0) {
      72           0 :                 share_type |= STYPE_PRINTQ;
      73           0 :                 TALLOC_FREE(sharetype);
      74           0 :                 return share_type;
      75             :         }
      76             : 
      77         708 :         TALLOC_FREE(sharetype);
      78         708 :         share_type |= STYPE_DISKTREE;
      79             : 
      80         708 :         return share_type;
      81             : }
      82             : 
      83             : /* This hardcoded value should go into a ldb database! */
      84         234 : const char *dcesrv_common_get_share_path(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, struct share_config *scfg)
      85             : {
      86           0 :         char *sharetype;
      87           0 :         char *p;
      88           0 :         char *path;
      89             : 
      90         234 :         sharetype = share_string_option(mem_ctx, scfg, SHARE_TYPE, SHARE_TYPE_DEFAULT);
      91             :         
      92         234 :         if (sharetype && strcasecmp(sharetype, "IPC") == 0) {
      93          18 :                 TALLOC_FREE(sharetype);
      94          18 :                 return talloc_strdup(mem_ctx, "");
      95             :         }
      96             : 
      97         216 :         TALLOC_FREE(sharetype);
      98             : 
      99         216 :         p = share_string_option(mem_ctx, scfg, SHARE_PATH, "");
     100         216 :         if (!p) {
     101           0 :                 return NULL;
     102             :         }
     103         216 :         if (p[0] == '\0') {
     104           0 :                 return p;
     105             :         }
     106         216 :         all_string_sub(p, "/", "\\", 0);
     107             :         
     108         216 :         path = talloc_asprintf(mem_ctx, "C:%s", p);
     109         216 :         TALLOC_FREE(p);
     110         216 :         return path;
     111             : }
     112             : 
     113             : /* This hardcoded value should go into a ldb database! */
     114          45 : uint32_t dcesrv_common_get_share_dfs_flags(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, struct share_config *scfg)
     115             : {
     116          45 :         return 0;
     117             : }
     118             : 
     119             : /* This hardcoded value should go into a ldb database! */
     120         117 : struct security_descriptor *dcesrv_common_get_security_descriptor(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, struct share_config *scfg)
     121             : {
     122         117 :         return NULL;
     123             : }

Generated by: LCOV version 1.14