On 03/28/16 04:05, Todd C. Miller wrote:
> I think it's best to just check the parent directories first and
> then create the temp name.
>
> - todd
This works for me and avoids my hacking around with new. I added a few
extra destination directories and it seems to hold up OK. Thanks!
paul@tiger:~/workspace/push/cm: /usr/bin/rdist -L syslog=all -d
HOST=aspireone
aspireone: updating host aspireone
aspireone: ./scripts: installing
aspireone: scripts: mkdir
aspireone: ./scripts/util: installing
aspireone: ./scripts/install: installing
aspireone: ./scripts/files: installing
aspireone: ./hosts/aspireone/etc/doas.conf: installing
aspireone: staging: mkdir
aspireone: staging/etc: mkdir
aspireone: staging/etc/one: mkdir
aspireone: staging/etc/one/two: mkdir
aspireone: staging/etc/one/two/three: mkdir
aspireone: ./hosts/aspireone/etc/rc.conf.local: installing
aspireone: cmdspecial "./scripts/install"
> Index: server.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/rdistd/server.c,v
> retrieving revision 1.40
> diff -u -p -u -r1.40 server.c
> --- server.c 22 Dec 2015 08:48:39 -0000 1.40
> +++ server.c 28 Mar 2016 02:01:32 -0000
> @@ -750,12 +750,9 @@ recvfile(char *new, opt_t opts, int mode
> /*
> * Create temporary file
> */
> - if ((f = mkstemp(new)) < 0) {
> - if (errno != ENOENT || chkparent(new, opts) < 0 ||
> - (f = mkstemp(new)) < 0) {
> - error("%s: create failed: %s", new, SYSERR);
> - return;
> - }
> + if (chkparent(new, opts) < 0 || (f = mkstemp(new)) < 0) {
> + error("%s: create failed: %s", new, SYSERR);
> + return;
> }
>
> /*
> @@ -1161,13 +1158,10 @@ recvlink(char *new, opt_t opts, int mode
> /*
> * Make new symlink using a temporary name
> */
> - if (mktemp(new) == NULL || symlink(dbuf, new) < 0) {
> - if (errno != ENOENT || chkparent(new, opts) < 0 ||
> - mktemp(new) == NULL || symlink(dbuf, new) < 0) {
> - error("%s -> %s: symlink failed: %s", new, dbuf,
> - SYSERR);
> - return;
> - }
> + if (chkparent(new, opts) < 0 || mktemp(new) == NULL ||
> + symlink(dbuf, new) < 0) {
> + error("%s -> %s: symlink failed: %s", new, dbuf, SYSERR);
> + return;
> }
>
> /*