Subject: Re: pkgsrc.txt and sudo
To: None <netbsd-docs@NetBSD.org>
From: Aleksey Cheusov <cheusov@tut.by>
List: netbsd-docs
Date: 04/29/2007 15:36:54
> On Sun, 29 Apr 2007, Aleksey Cheusov wrote:
>> > On Sat, 28 Apr 2007, Aleksey Cheusov wrote:
>> >> .if exists(${LOCALBASE}/bin/sudo)
>> >> SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
>> >> .endif
>> >>
>> >> First, this .if doesn't work.
>>
>> > What do you mean by "doesn't work"?
>> [session transcript deleted]
> You still haven't explained what you mean by "doesn't work". A
> transcript is not an explanation, and your transcript doesn't
> contain any evidence about whether or not ${LOCALBASE}/bin/sudo
> existed at the time the .if condition was evaluated.
Of course this file exists but .exists() returns false,
this is exactly what i'm talking about.
0 xxkb>grep -C1 SU_CMD /etc/mk.conf
.if exists(${LOCALBASE}/bin/sudo)
SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
.endif
0 xxkb>make show-var VARNAME=LOCALBASE
/usr/pkg
0 xxkb>make show-var VARNAME=SU_CMD
/usr/bin/su - root -c
0 xxkb>ls -la /usr/pkg/bin/sudo
-rws--x--x 2 root wheel 87672 Apr 29 01:33 /usr/pkg/bin/sudo
0 xxkb>test -f /usr/pkg/bin/sudo
0 xxkb>id
uid=10040(cheusov) gid=10001(syntagma) groups=0(wheel),5(operator),9(wsrc),13(games),1000(network),1004(cdrom),10001(syntagma),10002(synrus)
0 xxkb>
To find a problem
0 xxkb>ktrace make show-var VARNAME=SU_CMD
/usr/bin/su - root -c
0 xxkb>kdump | grep -C1 /bin/sudo
#
.if exists(${LOCALBASE}/bin/sudo)
SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
.endif
--
15964 1 make CALL __stat30(0x807b600,0xbfbfd188)
15964 1 make NAMI "/bin/sudo"
15964 1 make RET __stat30 -1 errno 2 No such file or directory
0 xxkb>
Of course, /bin/sudo doesn't exist.
Something is wrong with '.if exists(${LOCALBASE}/bin/sudo)',
variable LOCALBASE is expanded incorrectly.
I'm not expert in BSD make,
but this variable is probably substituted before
it is initialized in mk/defaults/mk.conf.
> It certainly works for me.
And doesn't for me. See above.
>> it doesn't help much if I use pkg_chk for building LOTS OF
>> packages using unpriviledged mode for building and sudo for
>> installing/packaging. The built will be stopped with unnecessary
>> prompt.
> I suggest that you install sudo before building anything else.
Each time I run pkg_chk or something similar I should remember that
sudo is installed? No, thanks, I better copy sudo to /usr/local just
like my favourite shell to /bin
--
Best regards, Aleksey Cheusov.