casper: convert macros to inline functions
In libcasper, the first argument to the function is a structure that represents a connection to Casper. On systems without Casper, macros are used to interpose the Casper functions to standard libc ones. This may cause errors/warnings that the variable is not used. With the inline function, there is no such problem.
This commit is contained in:
parent
3810732829
commit
8c121177f0
@ -66,24 +66,97 @@ int cap_pwd_limit_users(cap_channel_t *chan, const char * const *names,
|
||||
__END_DECLS
|
||||
|
||||
#else
|
||||
#define cap_getpwent(chan) getpwent()
|
||||
#define cap_getpwnam(chan, login) getpwnam(login)
|
||||
#define cap_getpwuid(chan, uid) getpwuid(uid)
|
||||
|
||||
#define cap_getpwent_r(chan, pwd, buffer, bufsize, result) \
|
||||
getpwent_r(pwd, buffer, bufsize, result)
|
||||
#define cap_getpwnam_r(chan, name, pwd, buffer, bufsize, result) \
|
||||
getpwnam_r(name, pwd, buffer, bufsize, result)
|
||||
#define cap_getpwuid_r(chan, uid, pwd, buffer, bufsize, result) \
|
||||
getpwuid_r(uid, pwd, buffer, bufsize, result)
|
||||
static inline struct passwd *
|
||||
cap_getpwent(cap_channel_t *chan __unused)
|
||||
{
|
||||
|
||||
#define cap_setpassent(chan, stayopen) setpassent(stayopen)
|
||||
#define cap_setpwent(chan) setpwent()
|
||||
#define cap_endpwent(chan) endpwent()
|
||||
return (getpwent());
|
||||
}
|
||||
|
||||
#define cap_pwd_limit_cmds(chan, cmds, ncmds) (0)
|
||||
#define cap_pwd_limit_fields(chan, fields, nfields) (0)
|
||||
#define cap_pwd_limit_users(chan, names, nnames, uids, nuids) (0)
|
||||
static inline struct passwd *
|
||||
cap_getpwnam(cap_channel_t *chan __unused, const char *login)
|
||||
{
|
||||
|
||||
return (getpwnam(login));
|
||||
}
|
||||
|
||||
static inline struct passwd *
|
||||
cap_getpwuid(cap_channel_t *chan __unused, uid_t uid)
|
||||
{
|
||||
|
||||
return (getpwuid(uid));
|
||||
}
|
||||
|
||||
static inline int
|
||||
cap_getpwent_r(cap_channel_t *chan __unused, struct passwd *pwd, char *buffer,
|
||||
size_t bufsize, struct passwd **result)
|
||||
{
|
||||
|
||||
return (getpwent_r(pwd, buffer, bufsize, result));
|
||||
}
|
||||
|
||||
static inline int
|
||||
cap_getpwnam_r(cap_channel_t *chan __unused, const char *name,
|
||||
struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result)
|
||||
{
|
||||
|
||||
return (getpwnam_r(name, pwd, buffer, bufsize, result));
|
||||
}
|
||||
|
||||
static inline int
|
||||
cap_getpwuid_r(cap_channel_t *chan __unused, uid_t uid, struct passwd *pwd,
|
||||
char *buffer, size_t bufsize, struct passwd **result)
|
||||
{
|
||||
|
||||
return (getpwuid_r(uid, pwd, buffer, bufsize, result));
|
||||
}
|
||||
|
||||
static inline int
|
||||
cap_setpassent(cap_channel_t *chan __unused, int stayopen)
|
||||
{
|
||||
|
||||
return (setpassent(stayopen));
|
||||
}
|
||||
|
||||
static inline void
|
||||
cap_setpwent(cap_channel_t *chan __unused)
|
||||
{
|
||||
|
||||
return (setpwent());
|
||||
}
|
||||
|
||||
static inline void
|
||||
cap_endpwent(cap_channel_t *chan __unused)
|
||||
{
|
||||
|
||||
return (endpwent());
|
||||
}
|
||||
|
||||
static inline int
|
||||
cap_pwd_limit_cmds(cap_channel_t *chan __unused,
|
||||
const char * const *cmds __unused, size_t ncmds __unused)
|
||||
{
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static inline int
|
||||
cap_pwd_limit_fields(cap_channel_t *chan __unused,
|
||||
const char * const *fields __unused, size_t nfields __unused)
|
||||
{
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static inline int
|
||||
cap_pwd_limit_users(cap_channel_t *chan __unused,
|
||||
const char * const *names __unused, size_t nnames __unused,
|
||||
uid_t *uids __unused, size_t nuids __unused)
|
||||
{
|
||||
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_CAP_PWD_H_ */
|
||||
|
@ -66,17 +66,60 @@ int cap_sysctl_limit(cap_sysctl_limit_t *limit);
|
||||
__END_DECLS
|
||||
|
||||
#else /* !WITH_CASPER */
|
||||
#define cap_sysctl(chan, name, namelen, oldp, oldlenp, newp, newlen) \
|
||||
sysctl((name), (namelen), (oldp), (oldlenp), (newp), (newlen))
|
||||
#define cap_sysctlbyname(chan, name, oldp, oldlenp, newp, newlen) \
|
||||
sysctlbyname((name), (oldp), (oldlenp), (newp), (newlen))
|
||||
#define cap_sysctlnametomib(chan, name, mibp, sizep) \
|
||||
sysctlnametomib((name), (mibp), (sizep))
|
||||
static inline int
|
||||
cap_sysctl(cap_channel_t *chan __unused, const int *name, u_int namelen,
|
||||
void *oldp, size_t *oldlenp, const void *newp, size_t newlen)
|
||||
{
|
||||
|
||||
#define cap_sysctl_limit_init(chan) (NULL)
|
||||
#define cap_sysctl_limit_name(limit, name, flags) (NULL)
|
||||
#define cap_sysctl_limit_mib(limit, mibp, miblen, flags) (NULL)
|
||||
#define cap_sysctl_limit(limit) (0)
|
||||
return (sysctl(name, namelen, oldp, oldlenp, newp, newlen));
|
||||
}
|
||||
|
||||
static inline int
|
||||
cap_sysctlbyname(cap_channel_t *chan __unused, const char *name,
|
||||
void *oldp, size_t *oldlenp, const void *newp, size_t newlen)
|
||||
{
|
||||
|
||||
return (sysctlbyname(name, oldp, oldlenp, newp, newlen));
|
||||
}
|
||||
|
||||
static inline int
|
||||
cap_sysctlnametomib(cap_channel_t *chan __unused, const char *name, int *mibp,
|
||||
size_t *sizep)
|
||||
{
|
||||
|
||||
return (sysctlnametomib(name, mibp, sizep));
|
||||
}
|
||||
|
||||
static inline cap_sysctl_limit_t *
|
||||
cap_sysctl_limit_init(cap_channel_t *limit __unused)
|
||||
{
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static inline cap_sysctl_limit_t *
|
||||
cap_sysctl_limit_name(cap_sysctl_limit_t *limit __unused,
|
||||
const char *name __unused, int flags __unused)
|
||||
{
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static inline cap_sysctl_limit_t *
|
||||
cap_sysctl_limit_mib(cap_sysctl_limit_t *limit __unused,
|
||||
const int *mibp __unused, u_int miblen __unused,
|
||||
int flags __unused)
|
||||
{
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static inline int
|
||||
cap_sysctl_limit(cap_sysctl_limit_t *limit __unused)
|
||||
{
|
||||
|
||||
return (0);
|
||||
}
|
||||
#endif /* WITH_CASPER */
|
||||
|
||||
#endif /* !_CAP_SYSCTL_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user