I'm aware that your example was the source, but unless my script intends to recompile the binary from source, there's really no point in it changing lightdm's source code. I was talking about editing the binary directly with sed, but as I suspected, it appears to be of limited use unless it's done to a string. Ex. I can use:
Code:
sed -i.bak 's/Using VT/Using RS/g' /sbin/lightdm
to change the binary directly, and the log file at next reboot will actually say "Using RS" instead of VT, but that appears to only work because "Using VT" is a string that's easy for sed to find in the lightdm binary. It's difficult, if not impossible to change actual code with that method.
I'm no C programmer, but it appears from the source code you've posted that this is the line that does the switching:
Code:
if (ioctl (console_fd, VT_ACTIVATE, n) < 0)
Where the if statement just checks its error code. My best guess for a fix if I was to edit the source code would be either to replace the content of vt_set_active with a single return line:
Code:
vt_set_active (gint number)
{
return;
}
or to change the line:
Code:
if (ioctl (console_fd, VT_ACTIVATE, n) < 0)
to read
but I don't see a way to do it with sed on the binary, so that idea is out.
The next idea I had, which I think may actually work would be to tell rc.local to wait for the log line that comes after:
Code:
if (ioctl (console_fd, VT_ACTIVATE, n) < 0)
before executing chvt. I don't have the lightdb.log in front of me, but I think the next log line was "Using VT" (I'll check later) so something like:
/etc/rc.local:
Code:
{ until grep -q "Using VT" /var/log/lightdm/lightdb.log; do sleep 1; done; /bin/chvt 2; } &
might do the trick.
Bookmarks