Date: Sat, 1 Jun 1996 20:59:50 -0700 From: pjf@cts.com (Paul Falstad) To: bde@freebsd.org Cc: hackers@freebsd.org Subject: bugs Message-ID: <9606012059.ZM575@zoof>
next in thread | raw e-mail | index | archive | help
Hi, here are some problems I encountered while trying to port na application to FreeBSD. I have workarounds for all of them, but I thought you might like to know. (1) mmap doesn't seem to work for extending a file. Here's a sample: ------------------------------------------ #include <stdio.h> #include <sys/mman.h> #include <sys/file.h> main() { int fd = open("newfile", O_RDWR|O_CREAT|O_EXCL, 0660); char *buf = mmap(NULL, 100, PROT_WRITE, MAP_SHARED, fd, 0); printf("%lx\n", buf); strcpy(buf, "hi!"); } ------------------------------------------ This test program dies when trying to do the strcpy. What we're trying to do is create a file using mmap() instead of write(). (This is in BSDI too.) (2) there seems to be some bad interation between setgid and setgroups. Here's a test program: ------------------------------------------ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/errno.h> main(int ac, char **av) { int f; if(setgroups(0, NULL) < 0) perror("setgroups"); if(setgid(atoi(av[1])) < 0) perror("setgid"); if(setuid(atoi(av[1])) < 0) perror("setuid"); f = access("somefile", X_OK); printf("%d %d\n", f, errno); } ------------------------------------------ Create a file called "somefile", chown it to root, chgrp it to group 123, chmod it 770. Run this program as root with argument "123". The setgroups() clears the group id set; setgid() sets the gid, but doesn't add it to the group id set (?). The result is that the access() fails, even though our group id has permission to execute the file. (This is in BSDI too) (3) There seems to be a problem with sys/signal.h. Try compiling the following program, called foo.cxx: ------------------------------------------ #include <sys/signal.h> void sigfunc(int s) { } main() // this is a C++ program { struct sigaction sa; sa.sa_handler = SIG_IGN; sa.sa_handler = sigfunc; sa.sa_handler = (sig_t) sigfunc; signal(SIGINT, sigfunc); signal(SIGINT, SIG_IGN); } ------------------------------------------ The result of compiling this is: foo.cxx: In function `int main()': foo.cxx:10: assignment to `void (*)()' from `void (*)(int)' foo.cxx:11: assignment to `void (*)()' from `void (*)(int)' foo.cxx:12: assignment to `void (*)()' from `void (*)(int)' It looks like sa_handler isn't declared to match SIG_IGN. Thanks... -- Paul Falstad, pjf@cts.com, 805-966-4935, http://www.ttinet.com/pjf/ work: pf@software.com, 805-882-2470, http://www.software.com Everywhere I go I'm asked if I think the university stifles writers. My opinion is that they don't stifle enough of them. -- Flannery O'Connor
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9606012059.ZM575>