segfault and uid problem
Hendrik Scholz <[email protected]>
| Newsgroups | gmane.comp.gnu.screen |
|---|---|
| Message-ID | <[email protected]> |
Hi!
I'm running FreeBSD/amd64 and when running a screen inside a screen it
used
segfault immediatly, .i.e.
user hscholz starts screen, su -m to root, screen -> segfault
(gdb) bt
#0 0x0000000200a7e868 in strncpy () from /lib/libc.so.5
#1 0x000000000040579e in Msg (err=2, fmt=0x7fffffffc7ca "") at
screen.c:1909
#2 0x0000000000414945 in MakeClientSocket (err=1) at socket.c:473
#3 0x00000000004149e1 in SendCreateMsg (
sty=0x7d5 <Address 0x7d5 out of bounds>, nwin=0x7fffffffe140)
at socket.c:621
#4 0x00000000004045f3 in main (ac=493, av=0x7fffffffe4a0) at
screen.c:1124
(gdb)
Reading the make output and the strncpy/strerror manpages it becomes
pretty
much evident that string.h has to be included:
--- screen.c.orig Sun Feb 15 14:49:28 2004
+++ screen.c Sun Feb 15 14:50:16 2004
@@ -35,6 +35,10 @@
#include <fcntl.h>
+#ifdef __FreeBSD__
+#include <string.h>
+#endif
+
#ifdef sgi
# include <sys/sysmacros.h>
#endif
@@ -1906,7 +1910,7 @@
p += strlen(p);
*p++ = ':';
*p++ = ' ';
- strncpy(p, strerror(err), buf + sizeof(buf) - p - 1);
+ strncpy(p, (char *)strerror(err), buf + sizeof(buf) - p - 1);
buf[sizeof(buf) - 1] = 0;
}
debug2("Msg('%s') (%#x);\n", buf, (unsigned int)display);
@@ -1960,7 +1964,7 @@
p += strlen(p);
*p++ = ':';
*p++ = ' ';
- strncpy(p, strerror(err), buf + sizeof(buf) - p - 1);
+ strncpy(p, (char *)strerror(err), buf + sizeof(buf) - p - 1);
buf[sizeof(buf) - 1] = 0;
}
debug3("Panic('%s'); display=%x displays=%x\n", buf, display,
displays);
Same is true for layer.c:
--- layer.c.orig Sun Feb 15 14:51:35 2004
+++ layer.c Sun Feb 15 14:51:57 2004
@@ -23,6 +23,10 @@
#include <sys/types.h>
+#ifdef __FreeBSD__
+#include <string.h>
+#endif
+
#include "config.h"
#include "screen.h"
#include "mark.h"
@@ -1097,7 +1101,7 @@
p += strlen(p);
*p++ = ':';
*p++ = ' ';
- strncpy(p, strerror(err), buf + sizeof(buf) - p - 1);
+ strncpy(p, (char *)strerror(err), buf + sizeof(buf) - p - 1);
buf[sizeof(buf) - 1] = 0;
}
debug2("LMsg('%s') (%#x);\n", buf, (unsigned int)flayer);
This is only needed on 64Bit FreeBSD platform as I couldn't get screen
on a i386 box to segfault but the includes are valid for both.
Once correctly patched screen doesn't core dump but prints:
[0.20] root@slurmcan:~ > screen
/tmp/screens/S-root/89382.ttyp3.slurmcan: No such file or directory
[0.20] root@slurmcan:~ >
[0.11] root@slurmcan:/tmp/screens > find . -type p
./S-hscholz/89382.ttyp3.slurmcan
[0.10] root@slurmcan:/tmp/screens >
Well, this looks like a uid vs. euid problem but let's investigate.
I did su -m which sets my uid to 0 but keeps my environment variables.
Ok, now let's use su - instead of su -m ... et voila screen works:
[0.10] root@slurmcan:/tmp/screens > find . -type p
./S-root/89869.ttyp4.slurmcan
./S-hscholz/89382.ttyp3.slurmcan
[0.04] root@slurmcan:/tmp/screens >
Since I don't want to read all the char *LoginName related code
and you definitly know better how to deal with this (beside the fact
that I'm hungry :)) I'll stop here.
In case someone needs access to the box or wants me to test code feel
free to send me a private mail.
Hendrik
--
Hendrik Scholz - [email protected] - http://www.raisdorf.net/
cell phone: 404-606-5324 (US) 0160-1570-272 (DE)
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/NhFolB/TM
---------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/gnu-screen/
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/