summaryrefslogtreecommitdiffabout
path: root/src/diskio.c
Side-by-side diff
Diffstat (limited to 'src/diskio.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/diskio.c68
1 files changed, 25 insertions, 43 deletions
diff --git a/src/diskio.c b/src/diskio.c
index fbd1050..35ba71e 100644
--- a/src/diskio.c
+++ b/src/diskio.c
@@ -58,9 +58,9 @@ concat_dir (const char *base, const char *name, size_t *pbaselen)
}
/* Create the directory DIR, eventually creating all intermediate directories
- starting from DIR + BASELEN, with owner UID and GID. */
+ starting from DIR + BASELEN. */
int
-create_hierarchy (char *dir, size_t baselen, uid_t uid, gid_t gid)
+create_hierarchy (char *dir, size_t baselen)
{
int rc;
struct stat st;
@@ -92,7 +92,7 @@ create_hierarchy (char *dir, size_t baselen, uid_t uid, gid_t gid)
*p = 0;
}
- rc = create_hierarchy (dir, baselen, uid, gid);
+ rc = create_hierarchy (dir, baselen);
if (rc == 0)
{
if (p)
@@ -103,11 +103,6 @@ create_hierarchy (char *dir, size_t baselen, uid_t uid, gid_t gid)
dir, strerror (errno));
rc = 1;
}
- if (chown (dir, uid, gid))
- {
- logmsg (LOG_NOTICE, _("cannot change ownership of %s: %s"),
- dir, strerror (errno));
- }
}
return rc;
}
@@ -116,18 +111,14 @@ create_hierarchy (char *dir, size_t baselen, uid_t uid, gid_t gid)
NAME). Use UID and GID as owner ids.
Do nothing if dry_run_mode is set. */
char *
-create_directory (const char *base, const char *name, uid_t uid, gid_t gid)
+create_directory (const char *base, const char *name)
{
size_t baselen;
char *dir = concat_dir (base, name, &baselen);
if (!dry_run_mode)
{
- int rc;
- wydawca_set_root_privs ();
- rc = create_hierarchy (dir, baselen, uid, gid);
- wydawca_set_privs (uid, gid);
- if (rc)
+ if (create_hierarchy (dir, baselen))
{
free (dir);
dir = NULL;
@@ -137,9 +128,9 @@ create_directory (const char *base, const char *name, uid_t uid, gid_t gid)
}
-/* Copy FILE to DST_FILE, creating the latter with owner UID and GID. */
+/* Copy FILE to DST_FILE. */
int
-copy_file (const char *file, const char *dst_file, uid_t uid, gid_t gid)
+copy_file (const char *file, const char *dst_file)
{
int in_fd, out_fd;
struct stat st;
@@ -223,10 +214,9 @@ copy_file (const char *file, const char *dst_file, uid_t uid, gid_t gid)
}
/* Move FILE to DST_FILE. If they reside on different devices, use copy_file
- + unlink.
- UID and GID give DST_FILE ownership. */
+ + unlink. */
int
-do_move_file (const char *file, const char *dst_file, uid_t uid, gid_t gid)
+do_move_file (const char *file, const char *dst_file)
{
int rc = 0;
@@ -234,7 +224,7 @@ do_move_file (const char *file, const char *dst_file, uid_t uid, gid_t gid)
{
if (errno == EXDEV)
{
- if (copy_file (file, dst_file, uid, gid))
+ if (copy_file (file, dst_file))
{
logmsg (LOG_CRIT, _("cannot copy %s to %s: %s"),
file, dst_file, strerror (errno));
@@ -299,13 +289,12 @@ tar_append_file (const char *archive, const char *file)
DST_DIR - Directory part of DST_FILE.
FILE - File part of DST_FILE; can contain subdirs.
ARCHIVE - Archive descriptor.
- UID, GID - Ownership
RELDIR - Directory part of FILE
Do nothing if dry_run_mode is set. */
int
backup_file (const char *dst_file, const char *dst_dir, const char *file,
- const struct archive_descr *archive, uid_t uid, gid_t gid,
+ const struct archive_descr *archive,
const char *reldir)
{
int rc = 0;
@@ -313,9 +302,9 @@ backup_file (const char *dst_file, const char *dst_dir, const char *file,
char *file_name;
if (archive->name[0] == '/')
- adir = create_directory (archive->name, reldir, uid, gid);
+ adir = create_directory (archive->name, reldir);
else
- adir = create_directory (dst_dir, archive->name, uid, gid);
+ adir = create_directory (dst_dir, archive->name);
if (!adir)
return 1;
@@ -347,7 +336,7 @@ backup_file (const char *dst_file, const char *dst_dir, const char *file,
file_name, archive_file_name);
if (!dry_run_mode)
{
- rc = do_move_file (file_name, archive_file_name, uid, gid);
+ rc = do_move_file (file_name, archive_file_name);
if (rc)
{
logmsg (LOG_ERR, _("backing `%s' up as `%s' failed: %s"),
@@ -366,7 +355,7 @@ backup_file (const char *dst_file, const char *dst_dir, const char *file,
logmsg (LOG_DEBUG, _("archiving `%s' to `%s'"), dst_file, file_name);
if (!dry_run_mode)
{
- rc = do_move_file (dst_file, file_name, uid, gid);
+ rc = do_move_file (dst_file, file_name);
if (rc)
logmsg (LOG_ERR, _("archiving `%s' as `%s' failed: %s"),
dst_file, file_name, strerror (errno));
@@ -380,7 +369,7 @@ backup_file (const char *dst_file, const char *dst_dir, const char *file,
for the argument description. */
int
do_archive_file (const char *dst_file, const char *dst_dir, const char *file,
- const struct archive_descr *archive, uid_t uid, gid_t gid,
+ const struct archive_descr *archive,
const char *reldir)
{
switch (archive->type)
@@ -389,7 +378,7 @@ do_archive_file (const char *dst_file, const char *dst_dir, const char *file,
break;
case archive_directory:
- return backup_file (dst_file, dst_dir, file, archive, uid, gid, reldir);
+ return backup_file (dst_file, dst_dir, file, archive, reldir);
case archive_tar:
if (tar_append_file (archive->name, dst_file))
@@ -415,8 +404,7 @@ dir_move_file (struct file_triplet *trp, const struct spool *spool,
{
char *dst_file;
int rc = 0;
- char *dst_dir = create_directory (spool->dest_dir, reldir,
- TRIPLET_UID (trp), TRIPLET_GID (trp));
+ char *dst_dir = create_directory (spool->dest_dir, reldir);
if (!dst_dir)
return 1;
@@ -428,12 +416,10 @@ dir_move_file (struct file_triplet *trp, const struct spool *spool,
if (access (dst_file, F_OK) == 0)
rc = do_archive_file (dst_file, dst_dir, trp->file[file_id].name,
- &spool->archive,
- TRIPLET_UID (trp), TRIPLET_GID (trp), reldir);
+ &spool->archive, reldir);
if (!dry_run_mode && rc == 0)
- rc = do_move_file (trp->file[file_id].name, dst_file,
- TRIPLET_UID (trp), TRIPLET_GID (trp));
+ rc = do_move_file (trp->file[file_id].name, dst_file);
free (dst_file);
free (dst_dir);
@@ -453,8 +439,7 @@ archive_single_file (struct file_triplet *trp, const struct spool *spool,
{
char *dst_file;
int rc = 0;
- char *dst_dir = create_directory (spool->dest_dir, reldir,
- TRIPLET_UID (trp), TRIPLET_GID (trp));
+ char *dst_dir = create_directory (spool->dest_dir, reldir);
if (!dst_dir)
return 1;
@@ -474,7 +459,7 @@ archive_single_file (struct file_triplet *trp, const struct spool *spool,
if (debug_level)
logmsg (LOG_DEBUG, _("archiving file `%s'"), dst_file);
rc = do_archive_file (dst_file, dst_dir, file_name, &spool->archive,
- TRIPLET_UID (trp), TRIPLET_GID (trp), reldir);
+ reldir);
if (rc == 0)
UPDATE_STATS (STAT_ARCHIVES);
}
@@ -543,8 +528,7 @@ dir_symlink_file (struct file_triplet *trp, const struct spool *spool,
{
int rc = 0;
struct saved_cwd cwd;
- char *dst_dir = create_directory (spool->dest_dir, reldir,
- TRIPLET_UID (trp), TRIPLET_GID (trp));
+ char *dst_dir = create_directory (spool->dest_dir, reldir);
char *src, *dst;
if (!dst_dir)
@@ -588,8 +572,7 @@ dir_symlink_file (struct file_triplet *trp, const struct spool *spool,
char *dir;
*p = 0;
- dir = create_directory (spool->dest_dir, dst,
- TRIPLET_UID (trp), TRIPLET_GID (trp));
+ dir = create_directory (spool->dest_dir, dst);
if (!dir)
rc = 1;
else
@@ -703,8 +686,7 @@ dir_rmsymlink_file (struct file_triplet *trp, const struct spool *spool,
char *dst_file;
int rc = 0;
char *signame;
- char *dst_dir = create_directory (spool->dest_dir, reldir,
- TRIPLET_UID (trp), TRIPLET_GID (trp));
+ char *dst_dir = create_directory (spool->dest_dir, reldir);
if (!dst_dir)
return 1;

Return to:

Send suggestions and report system problems to the System administrator.