Path: blob/main/lib/libcasper/services/cap_pwd/cap_pwd.h
48261 views
/*-1* Copyright (c) 2013 The FreeBSD Foundation2*3* This software was developed by Pawel Jakub Dawidek under sponsorship from4* the FreeBSD Foundation.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND16* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE19* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25* SUCH DAMAGE.26*/2728#ifndef _CAP_PWD_H_29#define _CAP_PWD_H_3031#ifdef HAVE_CASPER32#define WITH_CASPER33#endif3435#include <sys/cdefs.h>3637#ifdef WITH_CASPER38__BEGIN_DECLS3940struct passwd *cap_getpwent(cap_channel_t *chan);41struct passwd *cap_getpwnam(cap_channel_t *chan, const char *login);42struct passwd *cap_getpwuid(cap_channel_t *chan, uid_t uid);4344int cap_getpwent_r(cap_channel_t *chan, struct passwd *pwd, char *buffer,45size_t bufsize, struct passwd **result);46int cap_getpwnam_r(cap_channel_t *chan, const char *name, struct passwd *pwd,47char *buffer, size_t bufsize, struct passwd **result);48int cap_getpwuid_r(cap_channel_t *chan, uid_t uid, struct passwd *pwd,49char *buffer, size_t bufsize, struct passwd **result);5051int cap_setpassent(cap_channel_t *chan, int stayopen);52void cap_setpwent(cap_channel_t *chan);53void cap_endpwent(cap_channel_t *chan);5455int cap_pwd_limit_cmds(cap_channel_t *chan, const char * const *cmds,56size_t ncmds);57int cap_pwd_limit_fields(cap_channel_t *chan, const char * const *fields,58size_t nfields);59int cap_pwd_limit_users(cap_channel_t *chan, const char * const *names,60size_t nnames, uid_t *uids, size_t nuids);6162__END_DECLS6364#else6566static inline struct passwd *67cap_getpwent(cap_channel_t *chan __unused)68{6970return (getpwent());71}7273static inline struct passwd *74cap_getpwnam(cap_channel_t *chan __unused, const char *login)75{7677return (getpwnam(login));78}7980static inline struct passwd *81cap_getpwuid(cap_channel_t *chan __unused, uid_t uid)82{8384return (getpwuid(uid));85}8687static inline int88cap_getpwent_r(cap_channel_t *chan __unused, struct passwd *pwd, char *buffer,89size_t bufsize, struct passwd **result)90{9192return (getpwent_r(pwd, buffer, bufsize, result));93}9495static inline int96cap_getpwnam_r(cap_channel_t *chan __unused, const char *name,97struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result)98{99100return (getpwnam_r(name, pwd, buffer, bufsize, result));101}102103static inline int104cap_getpwuid_r(cap_channel_t *chan __unused, uid_t uid, struct passwd *pwd,105char *buffer, size_t bufsize, struct passwd **result)106{107108return (getpwuid_r(uid, pwd, buffer, bufsize, result));109}110111static inline int112cap_setpassent(cap_channel_t *chan __unused, int stayopen)113{114115return (setpassent(stayopen));116}117118static inline void119cap_setpwent(cap_channel_t *chan __unused)120{121122return (setpwent());123}124125static inline void126cap_endpwent(cap_channel_t *chan __unused)127{128129return (endpwent());130}131132static inline int133cap_pwd_limit_cmds(cap_channel_t *chan __unused,134const char * const *cmds __unused, size_t ncmds __unused)135{136137return (0);138}139140static inline int141cap_pwd_limit_fields(cap_channel_t *chan __unused,142const char * const *fields __unused, size_t nfields __unused)143{144145return (0);146}147148static inline int149cap_pwd_limit_users(cap_channel_t *chan __unused,150const char * const *names __unused, size_t nnames __unused,151uid_t *uids __unused, size_t nuids __unused)152{153154return (0);155}156#endif157158#endif /* !_CAP_PWD_H_ */159160161