This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
Re: [ITP] libfakesu 1.0
- From: Christian Franke <Christian dot Franke at t-online dot de>
- To: cygwin-apps at cygwin dot com
- Date: Wed, 10 Sep 2014 14:45:49 +0200
- Subject: Re: [ITP] libfakesu 1.0
- Authentication-results: sourceware.org; auth=none
- References: <53F9A8FA dot A2868696 at boland dot nl> <54076E3A dot 9080404 at t-online dot de> <540F4650 dot 365130F4 at boland dot nl>
D. Boland wrote:
Christian Franke wrote:
D. Boland wrote:
http://cygwin.boland.nl/x86/release/libfakesu/
A few notes regarding cygfakesu.c:
uid_t root_uid = 18;
gid_t root_gid = 544;
uid_t my_uid = -1;
gid_t my_gid = -1;
struct passwd my_pw;
struct group my_grp;
char str255[255];
...
uid_t uid_get(uid_t uid){
...
gid_t gid_get(gid_t gid){
...
etc...
Variables and functions not exported by the fakesu.h file should be
declared as static. Note that the cygfakesu.def file has no effect when
generating a static lib.
I added 'static' for un-exported symbols. Removed cygfakesu.def.
Thanks.
BTW: All these variables except root_uid/gid are not needed as static
globals:
my_uid is only used to pass the uid from uid_get/set() to get/set(e)uid().
my_pw and str255 are only needed because su_getpwnam() calls
getpwnam_r() instead of getpwnam().
etc.
int su_setgroups(int size, const gid_t *list){
...
gid_t l[s];
...
return setgroups(size, &l);
setgroups() 2nd parameter expects a type compatible to 'pointer to const
git_t'
The type of '&l' is 'pointer to array of git_t' :-)
(cosmetic in C, compilation would fail in C++):
I added typecasting, like this:
return setgroups(size, (gid_t *) &l);
No cast is needed, simply remove the '&' operator:
return setgroups(size, l);
Remember that a C array is implicitly converted to 'pointer to first
element' in many cases, including the above.
Another unrelated suggestion:
Add defines to fakesu.h for other uid/gid related functions which are
not implemented by fakesu:
#define setreuid(a,b) getruid_MISSING(a,b)
#define getpwnam_r(a,b,c,d,e) getpwnam_r_MISSING(a,b,c,d,e)
...
Thanks,
Christian