Added new options --no-mode, --no-owner and --no-time.

This commit is contained in:
Markus F.X.J. Oberhumer
2007-06-19 15:14:12 +02:00
parent fd7dbe5bd9
commit 1f1744a49a
4 changed files with 40 additions and 9 deletions
+2
View File
@@ -3,6 +3,8 @@ User visible changes for UPX
================================================================== ==================================================================
Changes in 3.01 (XX XXX 2007): Changes in 3.01 (XX XXX 2007):
* new options --no-mode, --no-owner and --no-time to disable preservation
of mode (file permissions), file ownership and timestamps.
* dos/exe: fixed an incorrect error message caused by a bug in * dos/exe: fixed an incorrect error message caused by a bug in
relocation handling relocation handling
* new format linux/mipsel supports ELF on [32-bit] R3000 * new format linux/mipsel supports ELF on [32-bit] R3000
+15
View File
@@ -56,6 +56,9 @@ void options_t::reset()
o->backup = -1; o->backup = -1;
o->overlay = -1; o->overlay = -1;
o->preserve_mode = true;
o->preserve_ownership = true;
o->preserve_timestamp = true;
o->console = CON_FILE; o->console = CON_FILE;
#if defined(__DJGPP__) #if defined(__DJGPP__)
@@ -646,6 +649,15 @@ static int do_option(int optc, const char *arg)
case 519: case 519:
opt->no_env = true; opt->no_env = true;
break; break;
case 526:
opt->preserve_mode = false;
break;
case 527:
opt->preserve_ownership = false;
break;
case 528:
opt->preserve_timestamp = false;
break;
// compression settings // compression settings
case 520: // --small case 520: // --small
if (opt->small < 0) if (opt->small < 0)
@@ -900,7 +912,10 @@ static const struct mfx_option longopts[] =
{"force-compress", 0, 0, 'f'}, // and compression of suspicious files {"force-compress", 0, 0, 'f'}, // and compression of suspicious files
{"info", 0, 0, 'i'}, // info mode {"info", 0, 0, 'i'}, // info mode
{"no-env", 0x10, 0, 519}, // no environment var {"no-env", 0x10, 0, 519}, // no environment var
{"no-mode", 0x10, 0, 526}, // do not preserve mode (permissions)
{"no-owner", 0x10, 0, 527}, // do not preserve ownership
{"no-progress", 0, 0, 516}, // no progress bar {"no-progress", 0, 0, 516}, // no progress bar
{"no-time", 0x10, 0, 528}, // do not preserve timestamp
{"output", 0x21, 0, 'o'}, {"output", 0x21, 0, 'o'},
{"quiet", 0, 0, 'q'}, // quiet mode {"quiet", 0, 0, 'q'}, // quiet mode
{"silent", 0, 0, 'q'}, // quiet mode {"silent", 0, 0, 'q'}, // quiet mode
+3
View File
@@ -69,6 +69,9 @@ struct options_t {
bool no_env; bool no_env;
bool no_progress; bool no_progress;
const char *output_name; const char *output_name;
bool preserve_mode;
bool preserve_ownership;
bool preserve_timestamp;
int small; int small;
int verbose; int verbose;
bool to_stdout; bool to_stdout;
+20 -9
View File
@@ -141,6 +141,8 @@ void do_one_file(const char *iname, char *oname)
// cannot rely on open() because of umask // cannot rely on open() because of umask
//int omode = st.st_mode | 0600; //int omode = st.st_mode | 0600;
int omode = 0600; int omode = 0600;
if (!opt->preserve_mode)
omode = 0666;
fo.sopen(tname,flags,shmode,omode); fo.sopen(tname,flags,shmode,omode);
// open succeeded - now set oname[] // open succeeded - now set oname[]
strcpy(oname,tname); strcpy(oname,tname);
@@ -209,21 +211,30 @@ void do_one_file(const char *iname, char *oname)
UNUSED(name); UNUSED(name);
#if defined(USE_UTIME) #if defined(USE_UTIME)
// copy time stamp // copy time stamp
struct utimbuf u; if (opt->preserve_timestamp)
u.actime = st.st_atime; {
u.modtime = st.st_mtime; struct utimbuf u;
r = utime(name, &u); u.actime = st.st_atime;
UNUSED(r); u.modtime = st.st_mtime;
r = utime(name, &u);
UNUSED(r);
}
#endif #endif
#if defined(HAVE_CHMOD) #if defined(HAVE_CHMOD)
// copy permissions // copy permissions
r = chmod(name, st.st_mode); if (opt->preserve_mode)
UNUSED(r); {
r = chmod(name, st.st_mode);
UNUSED(r);
}
#endif #endif
#if defined(HAVE_CHOWN) #if defined(HAVE_CHOWN)
// copy the ownership // copy the ownership
r = chown(name, st.st_uid, st.st_gid); if (opt->preserve_ownership)
UNUSED(r); {
r = chown(name, st.st_uid, st.st_gid);
UNUSED(r);
}
#endif #endif
} }