From owner-freebsd-current Mon Feb 5 19:30:27 2001 Delivered-To: freebsd-current@freebsd.org Received: from webcom.it (unknown [212.239.10.243]) by hub.freebsd.org (Postfix) with SMTP id 6368337B401 for ; Mon, 5 Feb 2001 19:30:08 -0800 (PST) Received: (qmail 9931 invoked by uid 1000); 6 Feb 2001 03:23:50 -0000 Date: Tue, 6 Feb 2001 04:23:49 +0100 From: Andrea Campi To: Brian Somers Cc: domi@saargate.de, freebsd-current@freebsd.org Subject: Re: Strange fopen() behaviour (was: xsane patch to maintainer) Message-ID: <20010206042348.A9639@webcom.it> References: <200102060319.f163J2610146@hak.lan.Awfulhak.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200102060319.f163J2610146@hak.lan.Awfulhak.org>; from brian@Awfulhak.org on Tue, Feb 06, 2001 at 03:19:01AM +0000 X-Echelon: BND CIA NSA Mossad KGB MI6 IRA detonator nuclear assault strike Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > lstat("/tmp//preview-level-0-15-b924dc",0xbfbfe894) ERR#2 'No such file or directory' ^^ surely this is not nice!! My guess is that the double slash is confusing everything... Anyway, I'm more interested in below: > @@ -2830,9 +2831,17 @@ > if (preview_make_image_path(p, sizeof(filename), filename, i)>=0) > { > umask(0177); /* create temporary file with "-rw-------" permissions */ > - fclose(fopen(filename, "wb")); /* make sure file exists, b = binary mode for win32 */ > - umask(XSANE_DEFAULT_UMASK); /* define new file permissions */ > - p->filename[i] = strdup(filename);/* store filename */ > + fp = fopen(filename, "wb"); /* make sure file exists, b = binary mode for win32 */ > + if (fp == NULL) { > + fprintf(stderr, "%s: could not create for preview-level %d: %s\n", filename, i, strerror(errno)); > + p->filename[i] = NULL; > + } > + else > + { > + fclose(fp); > + umask(XSANE_DEFAULT_UMASK); /* define new file permissions */ > + p->filename[i] = strdup(filename);/* store filename */ > + } I REALLY hope above code is NEVER EVER run as root, as this is a great recipe for interesting failures... /me hands Brian a few symlinks to /etc/master.passwd from /tmp If you are patching it, make sure you get it right, you'd do everybody a big favor. Bye, Andrea -- It is easier to fix Unix than to live with NT. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message