pppd stuck in dialing process - linux-kernel

i'm connecting several usb modems to my Ubuntu:
uname -a
Linux devlp 2.6.32-28-generic #55-Ubuntu SMP Mon Jan 10 21:21:01 UTC 2011 i686 GNU/Linux
pppd version: 2.4.5
i'm doing a test with 8 sierra wireless modems, and all of them are connected and work. each of them has a "ppp" interface.
after they are connected, i'm trying to reconnect ppp7, and at first, pppd fails, then in the second try it reaches the point where it says: "Serial connection established" and stuck. i tried all kill signals to kill that pppd without success, and the only way to terminate it is to plug-out the modem it tried to dial.
i looked for the exact place where the pppd get stuck and it's right over here:
int generic_establish_ppp (int fd)
{
int x;
if (new_style_driver) {
int flags;
FILE *f=fopen("/root/ptest.log","a");
fputs("before get channel\n",f);
fflush(f);
/* Open an instance of /dev/ppp and connect the channel to it */
if (ioctl(fd, PPPIOCGCHAN, &chindex) == -1) { // <<<<<<< STUCK HERE
error("Couldn't get channel number: %m");
goto err;
}
fputs("after get channel\n",f);
....
}
}
it looks like the problem is specifically with ppp7 - and it can be any modem so i don't think it's a modem problem, but what i don't understand is what really happens in that command? who is responsible for the answer? is it only the kernel? the modem driver? the modem itself? i don't quite understand what to do with that information since PPPIOCGCHAN documentation is very poor..
i thought at first that maybe pppd is not releasing the channel or ppp after disconnect so i compiled my own pppd version and added PPPIOCDISCONN and PPPIOCDETACH just to make sure my version is fine with that, and the results were the same.
what you think?

well i'm pretty i solved this one - I've added some lines in pppd before the ioctl command to make fd NONBLOCK :)

Related

Running awesome-client from a script executing as root

Running Awesome on Debian (11) testing
awesome v4.3 (Too long)
• Compiled against Lua 5.3.3 (running with Lua 5.3)
• D-Bus support: ✔
• execinfo support: ✔
• xcb-randr version: 1.6
• LGI version: 0.9.2
I'm trying to signal to Awesome when systemd triggers suspend. After fiddling with D-Bus directly for awhile and getting nowhere, I wrote a couple of functions that somewhat duplicate the functionality of signals.
I tested it by running the following command in a shell, inside of my Awesome session:
$ awesome-client 'require("lib.syskit").signal("awesome-client", "Hello world!")'
This runs just fine. A notification posts to the desktop "Hello world!" as expected. I added the path to my lib.syskit code to the $LUA_PATH in my ~/.xsessionrc. Given the error described below, I doubt this is an issue.
Now for the more difficult part. I put the following in a script located at /lib/systemd/system-sleep/pre-suspend.sh
#!/bin/bash
if [ "${1}" == "pre" ]; then
ERR=$(export DISPLAY=":0"; sudo -u naddan awesome-client 'require("lib.syskit").signal("awesome-client", "pre-suspend")' 2>&1)
echo "suspending at `date`, ${ERR}" > /tmp/systemd_suspend_test
elif [ "${1}" == "post" ]; then
ERR=$(export DISPLAY=":0"; sudo -u naddan awesome-client 'require("lib.syskit").signal("awesome-client", "post-suspend")' 2>&1)
echo "resuming at `date`, ${ERR}" >> /tmp/systemd_suspend_test
fi
Here's the output written to /tmp/systemd_suspend_test
suspending at Thu 22 Jul 2021 10:58:01 PM MDT, Failed to open connection to "session" message bus: /usr/bin/dbus-launch terminated abnormally without any error message
E: dbus-send failed.
resuming at Thu 22 Jul 2021 10:58:05 PM MDT, Failed to open connection to "session" message bus: /usr/bin/dbus-launch terminated abnormally without any error message
E: dbus-send failed.
Given that I'm already telling it the $DISPLAY that Awesome is running under (this is a laptop), and that I'm running awesome-client as my user, not root, what else am I missing that's keeping this from working?
Is there a better way that I could achieve telling Awesome when the system suspends?
awesome-client is a shell script. It is a thin wrapper around dbus-send. Thus, since you write "After fiddling with D-Bus directly for awhile and getting nowhere", I guess the same reasoning applies.
Given that I'm already telling it the $DISPLAY that Awesome is running under (this is a laptop), and that I'm running awesome-client as my user, not root, what else am I missing that's keeping this from working?
You are missing the address of the dbus session bus. For me, it is:
$ env | grep DBUS
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
Is there a better way that I could achieve telling Awesome when the system suspends?
Instead of sending a message directly to awesome via some script, you could use the existing mechanism for this: Dbus signals. These are broadcasts that interested parties can listen to.
Google suggests that there is already a PrepareForSleep signal:
https://serverfault.com/questions/573379/system-suspend-dbus-upower-signals-are-not-seen
Based on this, Google then gave me the following AwesomeWM lua code that listens for logind's PrepareForSleep signal (written by yours truely - thanks Google for finding that!):
https://github.com/awesomeWM/awesome/issues/344#issuecomment-328354719
local lgi = require("lgi")
local Gio = lgi.require("Gio")
local function listen_to_signals()
local bus = lgi.Gio.bus_get_sync(Gio.BusType.SYSTEM)
local sender = "org.freedesktop.login1"
local interface = "org.freedesktop.login1.Manager"
local object = "/org/freedesktop/login1"
local member = "PrepareForSleep"
bus:signal_subscribe(sender, interface, member, object, nil, Gio.DBusSignalFlags.NONE,
function(bus, sender, object, interface, signal, params)
-- "signals are sent right before (with the argument True) and
-- after (with the argument False) the system goes down for
-- reboot/poweroff, resp. suspend/hibernate."
if not params[1] then
-- This code is run before suspend. You can replace the following with something else.
require("gears.timer").start_new(2, function()
mytextclock:force_update()
end)
end
end)
end
listen_to_signals()

How to get the host name of kill signal sender in systemtap script

all,
I encounter a problem when use systemtap script.
I don't know how to get the host name of kill signal sender in systemtap script.
for example. I am execute kill -9 xclock_process_pid in server 'sf1'. at the same time, I run 1.stap -x xclock_process_pid to monitor xclock,
is there any method to obtain the server name 'sf1' in systemtap script when send a kill -9 xclock_process_pid in 'sf1'?
but I am encounter some problem. my 1.stap is shown below:
#!/usr/bin/env stap
function hostname:string () %{
STAP_RETURN(current->nsproxy->uts_ns->name.nodename);
%}
probe oneshot {
log(hostname())
}
when I run 'stap -g 1.stap' will reprot the following error Could you help me? semantic error: probe point mismatch at position 0 (alternatives: __nfs __scheduler __signal __tcpmib __vm _linuxmib _signal _sunrpc _syscall _vfs begin begin(number) end end(number) error error(number) generic ioblock ioblock_trace ioscheduler ioscheduler_trace ipmib irq_handler kernel kprobe kprocess linuxmib module(string) nd_syscall netdev never nfs nfsd perf process process(number) process(string) procfs procfs(string) scheduler scsi signal socket softirq stap staprun sunrpc syscall tcp tcpmib timer tty udp vfs vm workqueue): identifier 'oneshot' at systemtap.stap:87:7 while resolving probe point oneshot source: probe oneshot { ^ Pass 2: analysis failed. Try again with another '--vp 01' option.
In other words, you're asking how to get the hostname of the current machine. A TCP/IP-level hostname is not in reach. The sethostname(2) level name is not easy to reach, being hidden inside kernel variables behind locked utsname()-> fields.
If safety were not a problem, you could do it via an embedded-C function for 4.8 era kernels:
function hostname:string () %{
STAP_RETURN(current->nsproxy->uts_ns->name.nodename);
%}
probe oneshot {
log(hostname())
}
that you would run with stap -g ... (guru mode).

Find process where a particular system call returns a particular error

On OS X El Capitan, my log file system.log feels with hundreds of the following lines at times
03/07/2016 11:52:17.000 kernel[0]: hfs_clonefile: cluster_read failed - 34
but there is no indication of the process where this happens. Apart from that, Disk Utility could not find any fault with the file system. But I would still like to know what is going on and it seems to me that dtrace should be perfectly suited to find out that faulty process but I am stuck. I know of the function return probe but it seems to require the PID, e.g.
dtrace -n 'pidXXXX::hfs_clonefile:return { printf("ret: %d", arg1); }'
Is there a way to tell dtrace to probe all processes? And then how would I print the process name?
You can try something like this (I don't have access to an OS X machine to test it)
#!/usr/sbin/dtrace -s
# pragma D option quiet
fbt::hfs_clonefile:return
/ args[ 1 ] != 0 /
{
printf( "\n========\nprocess: %s, pid: %d, ret value: %d\n", execname, pid, args[ 1 ] );
/* get kernel and user-space stacks */
stack( 20 );
ustack( 20 );
}
For the fbt probes, args[ 1 ] is the value returned by the function.
The dTrace script will print out the process name, pid, and return value from hfs_clonefile() whenever the return value is not zero. It also adds the kernel and user space stack traces. That should be more than enough data for you to find the source of the errors.
Assuming it works on OS X, anyway.
You can use the syscall provider rather than the pid provider to do this sort of thing. Something like:
sudo dtrace -n 'syscall::hfs_clonefile*:return /errno != 0/ { printf("ret: %d\n", errno); }'
The above command is a minor variant of what's used within the built-in DTrace-based errinfo utility. You can view /usr/bin/errinfo in any editor to see how it works.
However, there's no hfs_clonefile syscall, as least as far as DTrace is concerned, on my El Capitan (10.11.5) system:
$ sudo dtrace -l -n 'syscall::hfs*:'
ID PROVIDER MODULE FUNCTION NAME
dtrace: failed to match syscall::hfs*:: No probe matches description
Also, unfortunately the syscall provider is prevented from tracing system processes by the System Integrity Protection feature introduced with El Capitan (macOS 10.11). So, you will have to disable SIP which makes your system less secure.

Can I use artoo-keyboard to listen to global keystrokes?

I'm building a text macro application for personal use and am using the artoo and artoo-keyboard gems to listen for keystrokes on my laptop's computer.
The goal is to fire events for global keystrokes, i.e. no particular window needs to be in focus.
Currently it is connected to /dev/ttyS4 and only registers keystrokes made when the terminal is in focus.
The reason I got /dev/ttyS3 is that someone advised I run dmesg | grep tty - this was the result.
With Artoo, the keyboard port is connected to like this:
connection :keyboard, adaptor: :keyboard, port: '/dev/tty/S4'
device :keyboard, driver: :keyboard, connection: :keyboard
Somebody else advised me to run cat /proc/bus/input/devices, and by doing so I see the following entry:
I: Bus=0011 Vendor=0001 Product=0001 Version=ab41
N: Name="AT Translated Set 2 keyboard"
P: Phys=isa0060/serio0/input0
S: Sysfs=/devices/platform/i8042/serio0/input/input3
U: Uniq=
H: Handlers=sysrq kbd event3
B: PROP=0
B: EV=120013
B: KEY=20000 20000000020 0 0 1500f02100000 3803078f900d401 feffffdfffefffff fffffffffffffffe
B: MSC=10
B: LED=7
I'm assuming this is the keyboard entry given the name.
I tried the Artoo connection command using port: 'isa0060/serio0/input0', but the code runs the exact same way.
If it's not clear what I'm trying to accomplish here, take a loot at this 10-second screencast, where I've established a listener to open the artoo.io homepage whenever the text hello world is typed: https://raw.githubusercontent.com/MaxPleaner/keyboard-macros/master/usage_screencast.gif
The problem is that it only works when typing in the terminal.
I am wondering what I can change to get it to work for global keystrokes.
I should mention I'm running Ubuntu 14.04 on a HP EliteBook 2540p laptop.
The creator of the artoo-keyboard gem responded to me on Github telling me this is impossible.
I make a global keyboard macro program for Linux using evtest and pty.
See http://github.com/maxpleaner/linux-keyboard-macros

how to know 2 lan pc is connetced with my program in php?

I have 4 PCs which are connected through the LAN. I am making a PHP program that will
differentiate each PC separately and i will keep each pc record.
But when i am getting an IP address i am getting same IP for all. I guess i should retrieve MAC address for all pcs separately, but i don't know how will i fetch MAC address.
I am using Linux OS.
Programing tips will be appreciated.
As far as I know, you cannot do this with PHP alone. However, if you have exec() rights on the server, the you might be able to use:
arp -a ipaddress
Where ipaddress is the IP address of the computer on your LAN. You would need to use something like regex to seperate the MAC address from the rest of the output.
I don't think that the mac-adress is included in the http-header. So it is probably hard to get it via php. I think you're better off trying to fix the ip-issue. Sorry I can't help you more.
Edit:
Actually... searching around a little I found a possible solution:
$mac = `ping -c 1 $ip && arp -a | grep $ip`
You probably have to parse the output though. I get:
xxx.xxx.local (192.168.0.10) at d5:c2:c3:13:a2:b1 [ether] on eth0
When doing arp -a 192.168.0.10
Edit:
Like the post under states, you would need exec-rights.
Edit:
Sorry, just realized that in order for this to work, you would need the ip... Which you don't have.
PEAR’s Net_Ping is a niffty wrapper class for executing ping calls from PHP. You can use it to check if a remote server is responding correctly. The library can be download from here.
pear install Net_Ping-2.4.4
<?php
require_once "Net/Ping.php";
$ping = Net_Ping::factory();
if(PEAR::isError($ping))
echo $ping->getMessage();
else
{
/* Number of packets to send */
$ping->setArgs(array('count' => 4));
$rawData = $ping->ping('google.com');
print_r($rawData);
}
?>

Resources