From 66d6de935a32fbf3aae2ef091b417a6572c8e6fd Mon Sep 17 00:00:00 2001 From: Martin Pärtel Date: Tue, 13 Mar 2012 16:53:07 +0200 Subject: Added --map. --- src/usermap.h | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/usermap.h (limited to 'src/usermap.h') diff --git a/src/usermap.h b/src/usermap.h new file mode 100644 index 0000000..8a74bb1 --- /dev/null +++ b/src/usermap.h @@ -0,0 +1,60 @@ +/* + Copyright 2012 Martin Pärtel + + This file is part of bindfs. + + bindfs is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + bindfs 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 + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with bindfs. If not, see . +*/ + +#ifndef INC_BINDFS_USERMAP_H +#define INC_BINDFS_USERMAP_H + +#include + +#include +#include +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +/* A map of user IDs to userIDs and group IDs to group IDs. */ +struct UserMap; +typedef struct UserMap UserMap; + +typedef enum UsermapStatus { + usermap_status_ok = 0, + usermap_status_duplicate_key = 1 +} UsermapStatus; + +UserMap *usermap_create(); +void usermap_destroy(UserMap *map); + +UsermapStatus usermap_add_uid(UserMap *map, uid_t from, uid_t to); +UsermapStatus usermap_add_gid(UserMap *map, gid_t from, gid_t to); + +const char* usermap_errorstr(UsermapStatus status); + +/* Returns the uid that u is mapped to, or u if none. */ +uid_t usermap_get_uid(UserMap *map, uid_t u); + +/* Returns the gid that g is mapped to, or g if none. */ +gid_t usermap_get_gid(UserMap *map, gid_t g); + +/* Returns the uid that u is mapped to, or -1 if none. */ +uid_t usermap_get_uid_or_none(UserMap *map, uid_t u); + +/* Returns the gid that g is mapped to, or -1 if none. */ +gid_t usermap_get_gid_or_none(UserMap *map, gid_t g); + +#endif -- cgit v1.2.3