Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 292026 Details for
Bug 320771
cp -a overwrites destination file with size 0 while cp -dpR copies the file correctly on nfs mounted file system
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Patch which will make unability of storing of security context non-fatal in cp -a
coreutils-5.97-requiresecuritycontext.patch (text/plain), 5.16 KB, created by
Ondrej Vasik
on 2008-01-17 16:28:41 UTC
(
hide
)
Description:
Patch which will make unability of storing of security context non-fatal in cp -a
Filename:
MIME Type:
Creator:
Ondrej Vasik
Created:
2008-01-17 16:28:41 UTC
Size:
5.16 KB
patch
obsolete
>diff -ur coreutils-5.97.orig/src/copy.c coreutils-5.97/src/copy.c >--- coreutils-5.97.orig/src/copy.c 2007-10-19 16:45:22.000000000 +0200 >+++ coreutils-5.97/src/copy.c 2007-10-31 13:37:20.000000000 +0100 >@@ -245,23 +245,32 @@ > dest_desc = open (dst_name, O_WRONLY | O_TRUNC | O_BINARY, dst_mode); > > #ifdef WITH_SELINUX >- if (dest_desc >= 0 && selinux_enabled && >- (x->preserve_security_context || x->set_security_context)) >+ if (x->preserve_security_context && 0 <= dest_desc) > { >- security_context_t con; >- if(getfscreatecon(&con) == -1) >+ security_context_t con = NULL; >+ if(getfscreatecon(&con) < 0) > { >- return_val = false; >- goto close_src_desc; >+ if (x->require_preserve_context) >+ { >+ error(0, errno, _("failed to get file system create context")); >+ return_val = false; >+ goto close_src_desc; >+ } > } > > if (con) > { >- if(fsetfilecon(dest_desc, con) == -1) >+ if(fsetfilecon(dest_desc, con) < 0) > { >- return_val = false; >- freecon(con); >- goto close_src_desc; >+ if (x->require_preserve_context) >+ { >+ error(0, errno, >+ _("failed to set security context of %s to %s"), >+ quote_n (0, dst_name), quote_n(1, con)); >+ return_val = false; >+ freecon(con); >+ goto close_src_desc; >+ } > } > freecon(con); > } >@@ -1438,10 +1447,12 @@ > { > if (setfscreatecon(con) < 0) > { >- error (0, errno, _("cannot set setfscreatecon %s"), quote (con)); >- if (x->require_preserve) { >+ error (0, errno, >+ _("cannot set default file creation context to %s"), >+ quote (con)); >+ if (x->require_preserve_context) { > freecon(con); >- return 1; >+ return false; > } > } > freecon(con); >@@ -1449,7 +1460,8 @@ > else { > if (( errno != ENOTSUP ) && ( errno != ENODATA )) { > error (0, errno, _("cannot lgetfilecon %s"), quote (src_name)); >- return 1; >+ if (x->require_preserve_context) >+ return 1; > } > } > } >diff -ur coreutils-5.97.orig/src/copy.h coreutils-5.97/src/copy.h >--- coreutils-5.97.orig/src/copy.h 2007-10-19 16:45:22.000000000 +0200 >+++ coreutils-5.97/src/copy.h 2007-10-31 13:39:14.000000000 +0100 >@@ -150,6 +150,18 @@ > it be zero. */ > bool require_preserve; > >+ /* Useful only when preserve_security_context is true. >+ If true, a failed attempt to preserve a file's security context >+ propagates failure "out" to the caller. If false, a failure to >+ preserve a file's security context does not change the invoking >+ application's exit status. Give diagnostics for failed syscalls >+ regardless of this setting. For example, with "cp --preserve=context" >+ this flag is "true", while with "cp -a", it is false. That means >+ "cp -a" attempts to preserve any security context, but does not >+ fail if it is unable to do so. */ >+ bool require_preserve_context; >+ >+ > /* If true, copy directories recursively and copy special files > as themselves rather than copying their contents. */ > bool recursive; >diff -ur coreutils-5.97.orig/src/cp.c coreutils-5.97/src/cp.c >--- coreutils-5.97.orig/src/cp.c 2007-10-19 16:45:22.000000000 +0200 >+++ coreutils-5.97/src/cp.c 2007-10-31 13:41:57.000000000 +0100 >@@ -754,6 +754,7 @@ > x->set_security_context = false; > #endif > >+ x->require_preserve_context = false; > x->require_preserve = false; > x->recursive = false; > x->sparse_mode = SPARSE_AUTO; >@@ -831,6 +832,7 @@ > > case PRESERVE_CONTEXT: > x->preserve_security_context = on_off; >+ x->require_preserve_context = on_off; > break; > > case PRESERVE_ALL: >@@ -838,7 +840,10 @@ > x->preserve_timestamps = on_off; > x->preserve_ownership = on_off; > x->preserve_links = on_off; >- x->preserve_security_context = on_off; >+ if (selinux_enabled) { >+ x->preserve_security_context = on_off; >+ x->require_preserve_context = on_off; >+ } > break; > > default: >@@ -902,7 +907,8 @@ > x.preserve_ownership = true; > x.preserve_mode = true; > x.preserve_timestamps = true; >- x.preserve_security_context = true; >+ if (selinux_enabled) >+ x.preserve_security_context = true; > x.require_preserve = true; > x.recursive = true; > break; >diff -ur coreutils-5.97.orig/src/install.c coreutils-5.97/src/install.c >--- coreutils-5.97.orig/src/install.c 2007-10-19 16:45:22.000000000 +0200 >+++ coreutils-5.97/src/install.c 2007-10-31 13:28:51.000000000 +0100 >@@ -184,6 +184,7 @@ > x->preserve_mode = false; > x->preserve_timestamps = false; > x->require_preserve = false; >+ x->require_preserve_context = false; > x->recursive = false; > x->sparse_mode = SPARSE_AUTO; > x->symbolic_link = false; >diff -ur coreutils-5.97.orig/src/mv.c coreutils-5.97/src/mv.c >--- coreutils-5.97.orig/src/mv.c 2007-10-19 16:45:22.000000000 +0200 >+++ coreutils-5.97/src/mv.c 2007-10-31 13:29:39.000000000 +0100 >@@ -137,6 +137,7 @@ > x->set_security_context = false; > #endif > x->require_preserve = false; /* FIXME: maybe make this an option */ >+ x->require_preserve_context = false; > x->recursive = true; > x->sparse_mode = SPARSE_AUTO; /* FIXME: maybe make this an option */ > x->symbolic_link = false;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 320771
: 292026