-/* $OpenBSD: extern.h,v 1.8 1997/01/24 19:41:20 millert Exp $ */
+/* $OpenBSD: extern.h,v 1.9 1997/01/26 10:33:22 downsj Exp $ */
/* $NetBSD: extern.h,v 1.5 1996/03/26 23:54:16 mrg Exp $ */
/*-
int chk_path __P((register char *, uid_t, gid_t));
void set_ftime __P((char *fnm, time_t mtime, time_t atime, int frc));
int set_ids __P((char *, uid_t, gid_t));
+int set_lids __P((char *, uid_t, gid_t));
void set_pmode __P((char *, mode_t));
int file_write __P((int, char *, register int, int *, int *, int, char *));
void file_flush __P((int, char *, int));
-/* $OpenBSD: file_subs.c,v 1.3 1996/06/23 14:20:33 deraadt Exp $ */
+/* $OpenBSD: file_subs.c,v 1.4 1997/01/26 10:33:22 downsj Exp $ */
/* $NetBSD: file_subs.c,v 1.4 1995/03/21 09:07:18 cgd Exp $ */
/*-
#if 0
static char sccsid[] = "@(#)file_subs.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: file_subs.c,v 1.3 1996/06/23 14:20:33 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: file_subs.c,v 1.4 1997/01/26 10:33:22 downsj Exp $";
#endif
#endif /* not lint */
arcn->name);
return(-1);
case PAX_SLK:
- if ((res = symlink(arcn->ln_name, arcn->name)) == 0)
- return(0);
+ res = symlink(arcn->ln_name, arcn->name);
break;
case PAX_CTG:
case PAX_HLK:
* we were able to create the node. set uid/gid, modes and times
*/
if (pids)
- res = set_ids(arcn->name, arcn->sb.st_uid, arcn->sb.st_gid);
+ res = ((arcn->type == PAX_SLK) ?
+ set_lids(arcn->name, arcn->sb.st_uid, arcn->sb.st_gid) :
+ set_ids(arcn->name, arcn->sb.st_uid, arcn->sb.st_gid));
else
res = 0;
+ /*
+ * symlinks are done now.
+ */
+ if (arcn->type == PAX_SLK)
+ return(0);
+
/*
* IMPORTANT SECURITY NOTE:
* if not preserving mode or we cannot set uid/gid, then PROHIBIT any
return(0);
}
+/*
+ * set_lids()
+ * set the uid and gid of a file system node
+ * Return:
+ * 0 when set, -1 on failure
+ */
+
+#if __STDC__
+int
+set_lids(char *fnm, uid_t uid, gid_t gid)
+#else
+int
+set_lids(fnm, uid, gid)
+ char *fnm;
+ uid_t uid;
+ gid_t gid;
+#endif
+{
+ if (lchown(fnm, uid, gid) < 0) {
+ syswarn(1, errno, "Unable to set file uid/gid of %s", fnm);
+ return(-1);
+ }
+ return(0);
+}
+
/*
* set_pmode()
* Set file access mode