public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* [ITP] libfakesu 1.0
@ 2014-08-24  8:52 D. Boland
  2014-08-24  9:02 ` Achim Gratz
  2014-09-03 19:38 ` Christian Franke
  0 siblings, 2 replies; 11+ messages in thread
From: D. Boland @ 2014-08-24  8:52 UTC (permalink / raw)
  To: Cygwin applications

Hi Group,

I intend to package this new Cygwin library. It was renamed due to name conflicts.
See the following thread for more information:

http://cygwin.com/ml/cygwin-apps/2014-08/msg00102.html

It's waiting for upload at:

http://cygwin.boland.nl/x86/release/libfakesu/

Daniel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [ITP] libfakesu 1.0
  2014-08-24  8:52 [ITP] libfakesu 1.0 D. Boland
@ 2014-08-24  9:02 ` Achim Gratz
  2014-08-25 18:53   ` D. Boland
  2014-09-03 19:38 ` Christian Franke
  1 sibling, 1 reply; 11+ messages in thread
From: Achim Gratz @ 2014-08-24  9:02 UTC (permalink / raw)
  To: cygwin-apps

D. Boland writes:
> It's waiting for upload at:
>
> http://cygwin.boland.nl/x86/release/libfakesu/

  cygmake install PREFIX=${D}/usr

You wouldn't need to do this if your Makefile was using $(DESTDIR) for
supporting staged builds.  Otherwise, packaging looks OK to me -- GTG.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Wavetables for the Terratec KOMPLEXER:
http://Synth.Stromeko.net/Downloads.html#KomplexerWaves

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [ITP] libfakesu 1.0
  2014-08-24  9:02 ` Achim Gratz
@ 2014-08-25 18:53   ` D. Boland
  2014-08-25 19:08     ` Ken Brown
  0 siblings, 1 reply; 11+ messages in thread
From: D. Boland @ 2014-08-25 18:53 UTC (permalink / raw)
  To: Cygwin applications

Hi Achim,

Achim Gratz wrote:
> 
> D. Boland writes:
> > It's waiting for upload at:
> >
> > http://cygwin.boland.nl/x86/release/libfakesu/
> 
>   cygmake install PREFIX=${D}/usr
> 
> You wouldn't need to do this if your Makefile was using $(DESTDIR) for
> supporting staged builds.  Otherwise, packaging looks OK to me -- GTG.

I changed the Makefile to use DESTDIR.

I also uploaded the fakesu release files via sftp, but I can't seem to create the
!ready file. If I do:

	put /dev/null -o !ready

I get:

Uploading /dev/null to /x86/-o
/dev/null is not a regular file

Daniel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [ITP] libfakesu 1.0
  2014-08-25 18:53   ` D. Boland
@ 2014-08-25 19:08     ` Ken Brown
  2014-08-28 15:45       ` Corinna Vinschen
  0 siblings, 1 reply; 11+ messages in thread
From: Ken Brown @ 2014-08-25 19:08 UTC (permalink / raw)
  To: cygwin-apps

On 8/25/2014 2:58 PM, D. Boland wrote:
> Hi Achim,
>
> Achim Gratz wrote:
>>
>> D. Boland writes:
>>> It's waiting for upload at:
>>>
>>> http://cygwin.boland.nl/x86/release/libfakesu/
>>
>>    cygmake install PREFIX=${D}/usr
>>
>> You wouldn't need to do this if your Makefile was using $(DESTDIR) for
>> supporting staged builds.  Otherwise, packaging looks OK to me -- GTG.
>
> I changed the Makefile to use DESTDIR.
>
> I also uploaded the fakesu release files via sftp, but I can't seem to create the
> !ready file. If I do:
>
> 	put /dev/null -o !ready
>
> I get:
>
> Uploading /dev/null to /x86/-o
> /dev/null is not a regular file

sftp doesn't support put -o, according to its man page.  The upload 
instructions recommend using lftp.

Ken

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [ITP] libfakesu 1.0
  2014-08-25 19:08     ` Ken Brown
@ 2014-08-28 15:45       ` Corinna Vinschen
  2014-09-09  4:07         ` D. Boland
  0 siblings, 1 reply; 11+ messages in thread
From: Corinna Vinschen @ 2014-08-28 15:45 UTC (permalink / raw)
  To: cygwin-apps; +Cc: D. Boland

[-- Attachment #1: Type: text/plain, Size: 1134 bytes --]

Daniel,

On Aug 25 15:07, Ken Brown wrote:
> On 8/25/2014 2:58 PM, D. Boland wrote:
> >Hi Achim,
> >
> >Achim Gratz wrote:
> >>
> >>D. Boland writes:
> >>>It's waiting for upload at:
> >>>
> >>>http://cygwin.boland.nl/x86/release/libfakesu/
> >>
> >>   cygmake install PREFIX=${D}/usr
> >>
> >>You wouldn't need to do this if your Makefile was using $(DESTDIR) for
> >>supporting staged builds.  Otherwise, packaging looks OK to me -- GTG.
> >
> >I changed the Makefile to use DESTDIR.
> >
> >I also uploaded the fakesu release files via sftp, but I can't seem to create the
> >!ready file. If I do:
> >
> >	put /dev/null -o !ready
> >
> >I get:
> >
> >Uploading /dev/null to /x86/-o
> >/dev/null is not a regular file
> 
> sftp doesn't support put -o, according to its man page.  The upload
> instructions recommend using lftp.

did you try Ken's tip in the meantime?  I still don't see the new
package in the release area...


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [ITP] libfakesu 1.0
  2014-08-24  8:52 [ITP] libfakesu 1.0 D. Boland
  2014-08-24  9:02 ` Achim Gratz
@ 2014-09-03 19:38 ` Christian Franke
  2014-09-09 18:21   ` D. Boland
  1 sibling, 1 reply; 11+ messages in thread
From: Christian Franke @ 2014-09-03 19:38 UTC (permalink / raw)
  To: cygwin-apps

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.


$ gcc -Wall cygfakesu.c
...
cygfakesu.c:52:2: warning: implicit declaration of function ‘getuid’ 
[-Wimplicit-function-declaration]
...

Include of unistd.h is missing.


> 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++):


Christian

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [ITP] libfakesu 1.0
  2014-08-28 15:45       ` Corinna Vinschen
@ 2014-09-09  4:07         ` D. Boland
  0 siblings, 0 replies; 11+ messages in thread
From: D. Boland @ 2014-09-09  4:07 UTC (permalink / raw)
  To: Cygwin applications

Hi Corinna,

Corinna Vinschen wrote:
> 
> Daniel,
> 
> On Aug 25 15:07, Ken Brown wrote:
> > On 8/25/2014 2:58 PM, D. Boland wrote:
> > >Hi Achim,
> > >
> > >Achim Gratz wrote:
> > >>
> > >>D. Boland writes:
> > >>>It's waiting for upload at:
> > >>>
> > >>>http://cygwin.boland.nl/x86/release/libfakesu/
> > >>
> > >>   cygmake install PREFIX=${D}/usr
> > >>
> > >>You wouldn't need to do this if your Makefile was using $(DESTDIR) for
> > >>supporting staged builds.  Otherwise, packaging looks OK to me -- GTG.
> > >
> > >I changed the Makefile to use DESTDIR.
> > >
> > >I also uploaded the fakesu release files via sftp, but I can't seem to create the
> > >!ready file. If I do:
> > >
> > >     put /dev/null -o !ready
> > >
> > >I get:
> > >
> > >Uploading /dev/null to /x86/-o
> > >/dev/null is not a regular file
> >
> > sftp doesn't support put -o, according to its man page.  The upload
> > instructions recommend using lftp.
> 
> did you try Ken's tip in the meantime?  I still don't see the new
> package in the release area...

Ahhh.... I'm back! My email was being blocked.

I followed Ken's tip. It worked. fakesu has already been added to the distribution.

Daniel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [ITP] libfakesu 1.0
  2014-09-03 19:38 ` Christian Franke
@ 2014-09-09 18:21   ` D. Boland
  2014-09-10 12:46     ` Christian Franke
  0 siblings, 1 reply; 11+ messages in thread
From: D. Boland @ 2014-09-09 18:21 UTC (permalink / raw)
  To: Cygwin applications

Hi Christian,

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.

> 
> $ gcc -Wall cygfakesu.c
> ...
> cygfakesu.c:52:2: warning: implicit declaration of function ‘getuid’
> [-Wimplicit-function-declaration]
> ...
> 
> Include of unistd.h is missing.

Added it.

> 
> > 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);

Would that satisfy c++?

Anyway, thanks for pointing it out.

Daniel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [ITP] libfakesu 1.0
  2014-09-09 18:21   ` D. Boland
@ 2014-09-10 12:46     ` Christian Franke
  2014-09-13  5:16       ` D. Boland
  0 siblings, 1 reply; 11+ messages in thread
From: Christian Franke @ 2014-09-10 12:46 UTC (permalink / raw)
  To: cygwin-apps

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [ITP] libfakesu 1.0
  2014-09-10 12:46     ` Christian Franke
@ 2014-09-13  5:16       ` D. Boland
  2014-09-13 11:15         ` Christian Franke
  0 siblings, 1 reply; 11+ messages in thread
From: D. Boland @ 2014-09-13  5:16 UTC (permalink / raw)
  To: Cygwin applications

Hi Christian,

Christian Franke wrote:
> 
> 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().

I did that to avoid writing into 'external' memory. Would calling getpwnam directly
be thread-safe?

> 
> 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)
> ...

I'll implement the missing functions.

Daniel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [ITP] libfakesu 1.0
  2014-09-13  5:16       ` D. Boland
@ 2014-09-13 11:15         ` Christian Franke
  0 siblings, 0 replies; 11+ messages in thread
From: Christian Franke @ 2014-09-13 11:15 UTC (permalink / raw)
  To: cygwin-apps

D. Boland wrote:
> Hi Christian,
>
> Christian Franke wrote:
>> ...
>> 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().
> I did that to avoid writing into 'external' memory. Would calling getpwnam directly
> be thread-safe?

No and this cannot be fixed because the function interface itself uses 
on a static pwd buffer as return value (and TLS is not allowed). As a 
consequence, the su_getpwnam() is also not thread safe. Calling 
thread-safe su_getpwnam_r() with a static result buffer makes the result 
thread-unsafe.

This would work without any extra buffers and is as thread-unsafe as the 
current version:

struct passwd *su_getpwnam(const char *name)
{
     struct passwd *pwd = getpwnam(name);
     if (!pwd)
         return NULL;
     if (pwd->pw_uid == root_uid)
         pwd->pw_uid = 0;
     if (pwd->pw_gid == root_gid)
         pwd->pw_gid = 0;
     return pwd;
}


Christian

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-09-13 11:15 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-24  8:52 [ITP] libfakesu 1.0 D. Boland
2014-08-24  9:02 ` Achim Gratz
2014-08-25 18:53   ` D. Boland
2014-08-25 19:08     ` Ken Brown
2014-08-28 15:45       ` Corinna Vinschen
2014-09-09  4:07         ` D. Boland
2014-09-03 19:38 ` Christian Franke
2014-09-09 18:21   ` D. Boland
2014-09-10 12:46     ` Christian Franke
2014-09-13  5:16       ` D. Boland
2014-09-13 11:15         ` Christian Franke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).