[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Cvs-cvs] Changes to ccvs/src/filesubr.c [signed-commits2]
From: |
Derek Robert Price |
Subject: |
[Cvs-cvs] Changes to ccvs/src/filesubr.c [signed-commits2] |
Date: |
Thu, 01 Dec 2005 10:58:54 -0500 |
Index: ccvs/src/filesubr.c
diff -u ccvs/src/filesubr.c:1.105.4.3 ccvs/src/filesubr.c:1.105.4.4
--- ccvs/src/filesubr.c:1.105.4.3 Thu Dec 1 01:48:59 2005
+++ ccvs/src/filesubr.c Thu Dec 1 15:58:44 2005
@@ -34,22 +34,19 @@
static int deep_remove_dir (const char *path);
+
+
/*
- * Copies "from" to "to".
+ * Copies FROM to TO. Ignores NOEXEC.
*/
void
-copy_file (const char *from, const char *to)
+force_copy_file (const char *from, const char *to)
{
struct stat sb;
struct utimbuf t;
int fdin, fdout;
ssize_t rsize;
- TRACE (TRACE_FUNCTION, "copy(%s,%s)", from, to);
-
- if (noexec)
- return;
-
/* If the file to be copied is a link or a device, then just create
the new link or device appropriately. */
if ((rsize = islink (from)) > 0)
@@ -119,6 +116,19 @@
+/*
+ * Copies FROM to TO. Honors NOEXEC.
+ */
+void
+copy_file (const char *from, const char *to)
+{
+ TRACE (TRACE_FUNCTION, "copy (%s, %s)", from, to);
+ if (noexec) return;
+ force_copy_file (from, to);
+}
+
+
+
/* FIXME-krp: these functions would benefit from caching the char * &
stat buf. */
@@ -339,6 +349,8 @@
return 0;
}
+
+
/*
* Change the mode of a file, either adding write permissions, or removing
* all write permissions. Either change honors the current umask setting.
@@ -346,8 +358,8 @@
* Don't do anything if PreservePermissions is set to `yes'. This may
* have unexpected consequences for some uses of xchmod.
*/
-void
-xchmod (const char *fname, int writable)
+static void
+ixchmod (const char *fname, bool writable, bool noexec)
{
struct stat sb;
mode_t mode, oumask;
@@ -366,16 +378,12 @@
oumask = umask (0);
(void) umask (oumask);
if (writable)
- {
mode = sb.st_mode | (~oumask
& (((sb.st_mode & S_IRUSR) ? S_IWUSR : 0)
| ((sb.st_mode & S_IRGRP) ? S_IWGRP : 0)
| ((sb.st_mode & S_IROTH) ? S_IWOTH : 0)));
- }
else
- {
mode = sb.st_mode & ~(S_IWRITE | S_IWGRP | S_IWOTH) & ~oumask;
- }
TRACE (TRACE_FUNCTION, "chmod(%s,%o)", fname, (unsigned int) mode);
@@ -385,6 +393,26 @@
if (chmod (fname, mode) < 0)
error (0, errno, "cannot change mode of file %s", fname);
}
+
+
+
+/* See description for ixchmod. Ignores NOEXEC. */
+void
+force_xchmod (const char *fname, bool writable)
+{
+ ixchmod (fname, writable, false);
+}
+
+
+
+/* See description for ixchmod. Honors NOEXEC. */
+void
+xchmod (const char *fname, bool writable)
+{
+ ixchmod (fname, writable, noexec);
+}
+
+
/*
* Rename a file and die if it fails
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Cvs-cvs] Changes to ccvs/src/filesubr.c [signed-commits2],
Derek Robert Price <=