cpdir.c (1b692a8c4495ea028986e0fd9ba81b156328a17e) cpdir.c (644af48df68c2e5b309de3f1287fe64a449c825d)
1/*-
2 * Copyright (C) 1996
3 * David L. Nugent. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 27 unchanged lines hidden (view full) ---

36#include <string.h>
37#include <stdlib.h>
38#include <unistd.h>
39#include <sys/types.h>
40#include <sys/stat.h>
41#include <sys/param.h>
42#include <dirent.h>
43
1/*-
2 * Copyright (C) 1996
3 * David L. Nugent. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 27 unchanged lines hidden (view full) ---

36#include <string.h>
37#include <stdlib.h>
38#include <unistd.h>
39#include <sys/types.h>
40#include <sys/stat.h>
41#include <sys/param.h>
42#include <dirent.h>
43
44#include "pw.h"
44#include "pwupd.h"
45
46void
47copymkdir(char const * dir, char const * skel, mode_t mode, uid_t uid, gid_t gid)
48{
49 char src[MAXPATHLEN];
50 char dst[MAXPATHLEN];
51 char lnk[MAXPATHLEN];

--- 24 unchanged lines hidden (view full) ---

76 else if (lstat(src, &st) == 0) {
77 if (strncmp(p, "dot.", 4) == 0) /* Conversion */
78 p += 3;
79 if (snprintf(dst, sizeof(dst), "%s/%s", dir, p) >= (int)sizeof(dst))
80 warn("warning: path too long '%s/%s' (skel file skipped)", dir, p);
81 else {
82 if (S_ISDIR(st.st_mode)) { /* Recurse for this */
83 if (strcmp(e->d_name, ".") != 0 && strcmp(e->d_name, "..") != 0)
45#include "pwupd.h"
46
47void
48copymkdir(char const * dir, char const * skel, mode_t mode, uid_t uid, gid_t gid)
49{
50 char src[MAXPATHLEN];
51 char dst[MAXPATHLEN];
52 char lnk[MAXPATHLEN];

--- 24 unchanged lines hidden (view full) ---

77 else if (lstat(src, &st) == 0) {
78 if (strncmp(p, "dot.", 4) == 0) /* Conversion */
79 p += 3;
80 if (snprintf(dst, sizeof(dst), "%s/%s", dir, p) >= (int)sizeof(dst))
81 warn("warning: path too long '%s/%s' (skel file skipped)", dir, p);
82 else {
83 if (S_ISDIR(st.st_mode)) { /* Recurse for this */
84 if (strcmp(e->d_name, ".") != 0 && strcmp(e->d_name, "..") != 0)
84 copymkdir(dst, src, (st.st_mode & 0777), uid, gid);
85 copymkdir(dst, src, st.st_mode & _DEF_DIRMODE, uid, gid);
85 chflags(dst, st.st_flags); /* propogate flags */
86 } else if (S_ISLNK(st.st_mode) && (len = readlink(src, lnk, sizeof(lnk))) != -1) {
87 lnk[len] = '\0';
88 symlink(lnk, dst);
89 lchown(dst, uid, gid);
90 /*
91 * Note: don't propogate special attributes
92 * but do propogate file flags

--- 38 unchanged lines hidden ---
86 chflags(dst, st.st_flags); /* propogate flags */
87 } else if (S_ISLNK(st.st_mode) && (len = readlink(src, lnk, sizeof(lnk))) != -1) {
88 lnk[len] = '\0';
89 symlink(lnk, dst);
90 lchown(dst, uid, gid);
91 /*
92 * Note: don't propogate special attributes
93 * but do propogate file flags

--- 38 unchanged lines hidden ---