No ns-3 log output when running scripts with sudo

877 views
Skip to first unread message

Peter

unread,
May 2, 2012, 6:34:19 PM5/2/12
to ns-3-users
Hello all,

When I run the first script in the tutorial (http://www.nsnam.org/docs/
release/3.13/tutorial/html/conceptual-overview.html#a-first-ns-3-
script) with sudo:

sudo ./waf --run scratch/myfirst

I do not see the ns-3 log message.

I have set NS_LOG: i.e. "export NS_LOG=FirstScriptExample=info". I
see the log message when I do not run with sudo.

I also tried redirecting stderr to a file:

sudo ./waf --run scratch/myfirst &>log

and didn't see the log message there.

I've been checking through the section on the logging module in the
manual (http://www.nsnam.org/docs/release/3.13/tutorial/html/
tweaking.html#using-the-logging-module) but haven't found anything
relevant yet (I certainly can't find any instance of 'sudo' with ctrl-
f).

Explanation of why I'm trying to do this:

In fact I'm interested in running a different script which requires
sudo privileges - specifically emu-ping, an example script
demonstrating usage of the emu net device - but it fails when I run it
and I would like to examine the progress using existing ns-3 log
statements (fyi I can see regular printlns - i.e. cout <<).

According to the comments in emu-net-device.cc I shouldn't have to run
emu-ping with sudo privileges, because emu-net device calls out to
another process (emu-sock-creator) to create the socket; however when
I try to run the script without sudo - i.e. "./waf --run emu-ping" -
it fails on insufficient privileges, so I then try "sudo ./waf --run
emu-ping", which leads me here.

Thanks!

Peter

unread,
May 8, 2012, 8:35:21 PM5/8/12
to ns-3-users
After checking into it I'm pretty sure the issue is not loss of the
definition of variables. I'm running this on CentOS 6.2, which
provides a -E option with sudo for preserving environment variables
(so I can run with "sudo -E ./waf ...").

Additionally if I use the 'su' command to become root, the NS_LOG
variable is still set; since I didn't use the -m option with 'su' to
preserve environment variables, I don't think the issue is a loss of
definition.

On May 8, 1:11 pm, Peter <scheib...@gmail.com> wrote:
> Recursive grep through all files in /var/log doesn't seem to turn up
> any of the log output. The output also does not show up in syslog.
>
> I'm having trouble finding info googling for phrases like "sudo ns3"
> or "sudo waf" with variations adding in "logging", "output", and
> "disappearing".
>
> Could something be going on with exporting NS_LOG not being recognized
> when I run as sudo (this could be a linux question)?
>
> Can folks run waf scripts as sudo and see log output? Or can anyone
> run the emu-ping script without sudo privileges?
>
> I'm currently looking into the possibility of not recognizing NS_LOG
> while running with sudo, but if anyone has a suggestion that would be
> awesome.
>
> Thanks!
> Peter

Peter

unread,
May 10, 2012, 6:08:25 PM5/10/12
to ns-3-users
So a few things have come up:

1. The setuid bit in a file's permissions can, in Wikipedia's words
"allow users to run an executable with the permissions of the
executable's owner or group."
2. The setuid bit can be enabled using the --enable-sudo option in waf
configuration. e.g. I used "./waf -d debug --enable-examples --enable-
sudo configure"
3. I ended up switching to using a tap-bridge, which uses essentially
the same technique as the emu-net-device: it forks another process to
perform all actions which require sudo privileges
4. When I configure the enable-sudo bit (as in (2)) I can run programs
that use the tap-bridge device fine without sudo
5. Programs using the emu-net-device still fail if I do not use sudo
6. The executables associated with the tap-bridge and emu-net device
have the same permissions, both have 'root' as owner, and [me] as the
group

So I'm not clear on why one fails and one doesn't. If I figure that
out I'll add an update.

Peter

unread,
May 8, 2012, 4:11:17 PM5/8/12
to ns-3-users
Recursive grep through all files in /var/log doesn't seem to turn up
any of the log output. The output also does not show up in syslog.

I'm having trouble finding info googling for phrases like "sudo ns3"
or "sudo waf" with variations adding in "logging", "output", and
"disappearing".

Could something be going on with exporting NS_LOG not being recognized
when I run as sudo (this could be a linux question)?

Can folks run waf scripts as sudo and see log output? Or can anyone
run the emu-ping script without sudo privileges?

I'm currently looking into the possibility of not recognizing NS_LOG
while running with sudo, but if anyone has a suggestion that would be
awesome.

Thanks!
Peter

On May 2, 3:34 pm, Peter <scheib...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages