From owner-freebsd-hackers Sat Jun 1 21:04:31 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id VAA28676 for hackers-outgoing; Sat, 1 Jun 1996 21:04:31 -0700 (PDT) Received: from harbor.silcom.com (harbor.silcom.com [199.201.128.1]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id VAA28668; Sat, 1 Jun 1996 21:04:27 -0700 (PDT) Received: from beach.silcom.com (root@beach.silcom.com [199.201.128.19]) by harbor.silcom.com (8.6.12/8.6.9) with ESMTP id VAA26865; Sat, 1 Jun 1996 21:05:50 -0700 Received: from zoof.cts.com by beach.silcom.com (8.6.12/SMI-4.1) id VAA19221; Sat, 1 Jun 1996 21:04:41 -0700 Received: from zoof.cts.com ([127.0.0.1]) by zoof.cts.com (post.office MTA v2.0 pre-alpha ID# 0-1001) with SMTP id AAA577; Sat, 1 Jun 1996 20:59:51 -0700 From: pjf@cts.com (Paul Falstad) Message-Id: <9606012059.ZM575@zoof> Date: Sat, 1 Jun 1996 20:59:50 -0700 X-Face: '{%PTQSjPtb*gV+:1\\^>-*AfWrG__v9_[KzFQ0{xa8CVcSp$1kgA X-Anagram: Salad, Flat Up X-Shakespearean-Insult: Thou mangled ill-nurtured mumble-news! X-Face-Info: Player being hurt, from Doom Reply-To: Paul Falstad To: bde@freebsd.org Subject: bugs Cc: hackers@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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 #include #include 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 #include #include #include 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 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