aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2010-07-22 19:45:47 -0500
committerMark Hatle <mark.hatle@windriver.com>2010-07-22 19:45:47 -0500
commit783cde155156ce1769082389ee53b60a1607eb0e (patch)
tree465f0184a11a29b4318b24507f584f5bbde5b7b2
parent52182f9e2a7dd613feebe5b1728ccd245f60cb44 (diff)
downloadprelink-cross-783cde155156ce1769082389ee53b60a1607eb0e.tar.gz
prelink-cross-783cde155156ce1769082389ee53b60a1607eb0e.tar.bz2
prelink-cross-783cde155156ce1769082389ee53b60a1607eb0e.zip
Sync to upstream r185
2010-07-22 Mark Hatle <mark.hatle@windriver.com> * Merge to upstream r185 * Resync dso-readonly.c from dso.c
-rw-r--r--trunk/ChangeLog.cross4
-rw-r--r--trunk/src/dso-readonly.c76
2 files changed, 48 insertions, 32 deletions
diff --git a/trunk/ChangeLog.cross b/trunk/ChangeLog.cross
index 3424127..a607b65 100644
--- a/trunk/ChangeLog.cross
+++ b/trunk/ChangeLog.cross
@@ -1,3 +1,7 @@
+2010-07-22 Mark Hatle <mark.hatle@windriver.com>
+ * Merge to upstream r185
+ * Resync dso-readonly.c from dso.c
+
2010-06-18 Mark Hatle <mark.hatle@windriver.com>
* Sync src/dso-readonly.c and ...
diff --git a/trunk/src/dso-readonly.c b/trunk/src/dso-readonly.c
index b32fa3c..3cfe838 100644
--- a/trunk/src/dso-readonly.c
+++ b/trunk/src/dso-readonly.c
@@ -1769,6 +1769,45 @@ set_security_context (const char *temp_name, const char *name,
}
int
+copy_fd_to_file (int fdin, const char *name, struct stat64 *st)
+{
+ struct stat64 stt;
+ off_t off = 0;
+ int err, fdout;
+ struct utimbuf u;
+
+ if (strcmp (name, "-") == 0)
+ fdout = 1;
+ else
+ fdout = wrap_open (name, O_WRONLY | O_CREAT, 0600);
+ if (fdout != -1
+ && fstat64 (fdin, &stt) >= 0
+ && send_file (fdout, fdin, &off, stt.st_size) == stt.st_size)
+ {
+ if (fchown (fdout, st->st_uid, st->st_gid) >= 0)
+ fchmod (fdout, st->st_mode & 07777);
+ if (strcmp (name, "-") != 0)
+ {
+ set_security_context (name, name, 1);
+ u.actime = time (NULL);
+ u.modtime = st->st_mtime;
+ wrap_utime (name, &u);
+ close (fdout);
+ }
+ return 0;
+ }
+ else if (fdout != -1)
+ {
+ err = errno;
+ if (strcmp (name, "-") == 0)
+ close (fdout);
+ }
+ else
+ err = errno;
+ return err;
+}
+
+int
update_dso (DSO *dso, const char *orig_name)
{
int rdwr = dso_is_rdwr (dso);
@@ -1778,7 +1817,7 @@ update_dso (DSO *dso, const char *orig_name)
char *name1, *name2;
struct utimbuf u;
struct stat64 st;
- int fdin, fdout;
+ int fdin;
switch (write_dso (dso))
{
@@ -1832,39 +1871,12 @@ update_dso (DSO *dso, const char *orig_name)
{
if (fdin != -1)
{
- struct stat64 stt;
- off_t off = 0;
- int err;
- if (strcmp (name1, "-") == 0)
- fdout = 1;
- else
- fdout = wrap_open (name1, O_WRONLY | O_CREAT, 0600);
- if (fdout != -1
- && fstat64 (fdin, &stt) >= 0
- && send_file (fdout, fdin, &off, stt.st_size) == stt.st_size)
- {
- close (fdin);
- if (fchown (fdout, st.st_uid, st.st_gid) >= 0)
- fchmod (fdout, st.st_mode & 07777);
- if (strcmp (name1, "-") != 0)
- {
- set_security_context (name1, name1, 1);
- wrap_utime (name1, &u);
- close (fdout);
- }
- wrap_unlink (name2);
- return 0;
- }
- else if (fdout != -1)
- {
- err = errno;
- if (strcmp (name1, "-") == 0)
- close (fdout);
- }
- else
- err = errno;
+ int err = copy_fd_to_file (fdin, name1, &st);
+
close (fdin);
wrap_unlink (name2);
+ if (err == 0)
+ return 0;
error (0, err, "Could not rename nor copy temporary to %s",
name1);
return 1;