summaryrefslogtreecommitdiff
path: root/open-vm-tools/lib/include/hgfsServerPolicy.h
blob: 9919226e5afbd7b40b4f1ace9a51357a435acd3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*********************************************************
 * Copyright (C) 1998-2015 VMware, Inc. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation version 2.1 and no later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
 *
 *********************************************************/

#ifndef _HGFS_SERVER_POLICY_H_
#define _HGFS_SERVER_POLICY_H_

#include "vm_basic_types.h"
#include "hgfs.h"
#include "dbllnklst.h"
#include "cpName.h"
#include "hgfsServer.h"

/*
 * Name of share that corresponds to the root of the server's
 * filesystem.
 */
#define HGFS_SERVER_POLICY_ROOT_SHARE_NAME "root"

Bool
HgfsServerPolicy_Init(HgfsInvalidateObjectsFunc *invalidateObjects, HgfsRegisterSharedFolderFunc *registerFolder);

Bool
HgfsServerPolicy_Cleanup(void);


typedef uint32 HgfsShareOptions;

/*
 * Structure representing one shared folder. We maintain a list of
 * these to check accesses against.
 */
typedef struct HgfsSharedFolder {
   DblLnkLst_Links links;
   char *name;          /* Name of share */
   char *path;          /*
                         * Path of share in server's filesystem. Should
                         * not include final path separator.
                         */
   char *shareTags;     /* Tags associated with this share (comma delimited). */
   size_t shareTagsLen; /* Length of shareTag string */
   size_t nameLen;      /* Length of name string */
   size_t pathLen;      /* Length of path string */
   Bool readAccess;     /* Read permission for this share */
   Bool writeAccess;    /* Write permission for this share */
   HgfsShareOptions configOptions; /* User-config options. */
   HgfsSharedFolderHandle handle;  /* Handle assigned by HGFS server
                                    * when the folder was registered with it.
                                    * Policy package keeps the context and returns
                                    * it along with other shared folder properties.
                                    * Keeping it here ensures consistent lookup all
                                    * properties of the shared folder which takes into
                                    * account such details like case sensitive/case
                                    * insensitive name lookup.
                                    */
} HgfsSharedFolder;

/* Per share user configurable options. */
#define HGFS_SHARE_HOST_DEFAULT_CASE  (1 << 0)
#define HGFS_SHARE_FOLLOW_SYMLINKS    (1 << 1)

typedef struct HgfsServerPolicy_ShareList {
   size_t count;
   char **shareNames;
} HgfsServerPolicy_ShareList;

/* Defined in hgfsServerInt.h */
HgfsGetNameFunc HgfsServerPolicy_GetShares;
HgfsInitFunc HgfsServerPolicy_GetSharesInit;
HgfsCleanupFunc HgfsServerPolicy_GetSharesCleanup;

HgfsNameStatus
HgfsServerPolicy_GetSharePath(char const *nameIn,         // IN:
                              size_t nameInLen,           // IN:
                              HgfsOpenMode mode,          // IN:
                              size_t *sharePathLen,       // OUT:
                              char const **sharePath);    // OUT:
HgfsNameStatus
HgfsServerPolicy_GetShareMode(char const *nameIn,        // IN: Share name to retrieve
                              size_t nameInLen,          // IN: Length of Share name
                              HgfsOpenMode *mode);       // OUT: Share's access mode
HgfsNameStatus
HgfsServerPolicy_GetShareOptions(char const *nameIn,        // IN: Share name
                          size_t nameInLen,                 // IN: Share name length
                          HgfsShareOptions *configOptions); // OUT: Share config options

Bool
HgfsServerPolicy_IsShareOptionSet(HgfsShareOptions shareOptions,  // IN: Config options
                                  uint32 option);                 // IN: Option to check
HgfsNameStatus
HgfsServerPolicy_ProcessCPName(char const *nameIn,            // IN: name in CPName form
                               size_t nameInLen,              // IN: length of the name
                               Bool *readAccess,              // OUT: Read permissions
                               Bool *writeAccess,             // OUT: Write permissions
                               HgfsSharedFolderHandle *handle,// OUT: folder handle
                               char const **shareBaseDir);    // OUT: Shared directory

void
HgfsServerPolicy_FreeShareList(HgfsServerPolicy_ShareList *shareList); // IN: list to free

HgfsServerPolicy_ShareList *
HgfsServerPolicy_GetSharesWithTag(const char *tag); // IN: tag to search for

Bool
HgfsServerPolicy_CheckMode(HgfsOpenMode mode,          // IN: mode to check
                           Bool writePermissions,      // IN: callers write permissions
                           Bool readPermissions);      // IN: callers read permissions

#endif // _HGFS_SERVER_POLICY_H_