OESF Portables Forum
Everything Else => General Support and Discussion => Zaurus General Forums => Archived Forums => Security and Networking => Topic started by: sdjf on April 18, 2007, 12:48:15 am
-
Has anyone got logging of dhcpcd sessions working? I see in the man page that it takes more than just enabling the logging in /etc/syslog.conf. I can't test this on my Z as I only have dialup, but I need to know so we can debug problems more easily when people test using my scripts on dhcpcd connections.
I believe the call to dhcpcd probably needs the -d flag in order to send output to the log, and I think we need to see which process is calling it to do that.
I did see on the web that it's possible to get the debugging output by calling dhcpcd from the command line, but I would like to make it happen automatically when people use their GUIs to get online.
If nobody has figured out how to get it working on your type of setup, could you run the following three lines when dhcpcd is active and you are online?
array=(`ps -C dhcpcd --noheader -o " %p %P"`)
echo dhcpcd pid is ${array[0]} parent is ${array[1]}
ps ${array[0]}; ps ${array[1]} | tail -n1
Oh, if all you have is BusyBox ps, the above won't work. Instead of getting information about dhcpcd's parent, you'll get a listing for all active processes on your Zaurus, as BusyBox ps has no options.
If you want to install a better ps, I have posted more information about doing that at http://www.sdjf.esmartdesign.com/commands/ps.html (http://www.sdjf.esmartdesign.com/commands/ps.html)
Thanks,
sdjf
-
I get the following to the screen:
dhcpcd pid is PID parent is Uid
and
root-:) ./ps-3100 ${array[0]}; ./ps-3100 ${array[1]} | tail -n1
ps: error: Unsupported option (BSD syntax)
usage: ps -[Unix98 options]
ps [BSD-style options]
ps --[GNU-style long options]
ps --help for a command summary
ps: error: User name does not exist.
usage: ps -[Unix98 options]
ps [BSD-style options]
ps --[GNU-style long options]
ps --help for a command summary
root-:)
-
Hmmm. what does your busybox ps show when you are online? do you use dhcpcd? [Edit: I thought you did...maybe you ran when dhcpcd was not active?]
I suppose we should surround the array elements with quotes so the full list appears if dhcpcd is not active:
ps "${array[0]}"; ps "${array[1]}" | tail -n1
Or more complicated but more sure of results:
if [[ "${array[0]}" -gt "0" ]]; then
ps ${array[0]}; ps ${array[1]} | tail -n1
else
ps
fi
No sense running ps on an empty array. What protocol do you use to get online?
thanks,
sdjf
-
I used ps and grep to confirm that dhcpd wasn't running
I stuck my WiFi card in and tested to make sure I had an Internet connection
I used ps and grep to determine that dhcpd was indeed now running
I copied and pasted what you had in your first post into a terminal and ran them.
I'll try your suggestions later tnite.
-
if you get this before the test please also post the grep and busybox ps if the code still doesn't work.
you might also do a "ps-3100 ax" in that case.
thanks so much,
sdjf
-
I see what happened! In the array statement, you used BusyBox ps instead of sharp's.
use this instead on that line:
array=(`./ps-3100 -C dhcpcd --noheader -o " %p %P"`)
You had entered:
array=(`ps -C dhcpcd --noheader -o " %p %P"`)__
So of course it spit back the first 2 words in busybox's header.
-
root-:) array=(`./ps-3100 -C dhcpcd --noheader -o " %p %P"`)
root-:) echo dhcpcd pid is ${array[0]} parent is ${array[1]}
dhcpcd pid is 2090 parent is 1
root-:) ./ps-3100 ${array[0]}; ps ${array[1]} | tail -n1
PID TTY STAT TIME COMMAND
2090 ? S 0:00 /sbin/dhcpcd -N wlan0
2127 root 524 S tail -n1
root-:)
-
This time the final ps used was busybox's. Let's try an alias:
alias ps="./ps-3100"
array=(`ps -C dhcpcd --noheader -o " %p %P"`)
echo dhcpcd pid is ${array[0]} parent is ${array[1]}
ps ${array[0]}; ps ${array[1]} | tail -n1
alias ps="ps" # return to normal here
sdjf
-
root-:) alias ps="./ps-3100"
root-:) array=(`ps -C dhcpcd --noheader -o " %p %P"`)
root-:) echo dhcpcd pid is ${array[0]} parent is ${array[1]}
dhcpcd pid is 3013 parent is 1
root-:) ps ${array[0]}; ps ${array[1]} | tail -n1
PID TTY STAT TIME COMMAND
3013 ? S 0:00 /sbin/dhcpcd -N wlan0
1 ? S 0:43 ini
-
Bingo! Thank you. That tells me that either your dhcpcd wlan0 is always up, started at initialization, or that the process that called dhcpcd is no longer active.
Anyone know what calls dhcpcd? An "lsof" might yield data if it got run just before dhcpcd happened. Hmmm.
I don't know what to read to figure this out.
sdjf
-
Eureka! I think I've found it, at least for Sharp ROMs.
In /etc/pcmcia/network, I would try adding a -d right
after /sbin/dhcpcd, and before $HN, on both of the following two lines to get debugging output to happen automatically. On my copy, they are lines 82 and 87 according to grep.
/sbin/dhcpcd $HN $DEVICE >/dev/null 2>&1 || exit 1
/sbin/dhcpcd $HN -c $L $DEVICE >/dev/null 2>&1
I believe that the above, after also adding "local0.* /var/log/dhcpcd.log" to /etc/syslog.conf, will do the trick. I think pdaXii13 uses a different scheme, so I still don't know what to do there.
If anyone tries testing this, let me know what happens. Again, I'm sorry I can't test it on my Z because all I have is dialup.
The basic info on debugging output for dhcpcd is in the man page for dhcpcd...the challenge has been in finding where it gets called.
sdjf
-
/etc/pcmcia/network has this in it:
elif is_true $DHCP; then
bootp_setup
HN=${DHCP_HOSTNAME:+-h $DHCP_HOSTNAME}
TO=${DHCP_TIMEOUT:+-t $DHCP_TIMEOUT}
if [ -x /sbin/dhcpcd ]; then
# This is a version check: I know it looks weird
if /sbin/dhcpcd --help 2>&1 | grep -q DHCP; then
/sbin/dhcpcd -N $HN $TO $DEVICE >/dev/null 2>&1 || exit 1
else
# Jump through hoops for lame 0.70-era dhcpcd
L=/var/run/dhcp-lock-$DEVICE
/bin/echo "#!/bin/sh\nrm $L" > $L; chmod +x $L
/sbin/dhcpcd -N $HN -c $L $DEVICE >/dev/null 2>&1
for t in 0 1 2 3 4 5 6 7 8 9; do
sleep 2; if [ ! -e $L ]; then break; fi
done
rm -f $L
if [ -e /etc/dhcpc/resolv.conf ]; then
echo "# $DEVICE begin" > $RESOLV.N
(just part of file)
-
Oh, how cool! The line of interest added a "-N":
/sbin/dhcpcd -N $HN -c $L $DEVICE >/dev/null 2>&1_
And the -N, according to the man page:
"Prevents dhcpcd from replacing existing /etc/ntp.conf file."
So, if you want to log what's going on, I should think it would not hurt to add a "-d":
/sbin/dhcpcd -d -N $HN -c $L $DEVICE >/dev/null 2>&1
The version check is different...on my version, they enter options that do not exist to trigger an error/help message.
if /sbin/dhcpcd -XYZZY 2>&1 | grep -q DHCP ; then_
/sbin/dhcpcd $HN $DEVICE >/dev/null 2>&1 || exit 1_
Unsure whether a -d would hurt or be necessary in your other /sbin/dhcpcd lines, but I think you probably would need it on:
/sbin/dhcpcd -d -N $HN $TO $DEVICE >/dev/null 2>&1 || exit 1
-
Looking at the pdaXrom howto here, I see dhcpcd gets called by the "wifiup" script.
There's a line "dhcpcd wlan0" which I would imagine could have debugging added like thus:
dhcpcd -d wlan0
Your system may use this instead of the "network" script, which is more in line with what I'd read elsewhere.
sdjf