vipw: do not let editor to inherit open file descriptors
PATCH 1/4 vipw: do not let editor to inherit open file descriptors
--- login-utils/vipw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
login-utils/vipw.c +2 -2
@@ -257,7 +257,7 @@ static void edit_file(int is_shadow)if (lckpwdf () <0 )err (EXIT_FAILURE ,_ ("cannot get lock" )); - passwd_file =open (orig_file,O_RDONLY ,0 ); + passwd_file =open (orig_file,O_RDONLY |O_CLOEXEC ,0 );if (passwd_file <0 )err (EXIT_FAILURE ,_ ("cannot open %s" ), orig_file); tmp_fd =pw_tmpfile (passwd_file);
@@ -275,7 +275,7 @@ static void edit_file(int is_shadow)if (end.st_nlink ==0 ) {if (close_stream (tmp_fd) !=0 )err (EXIT_FAILURE ,_ ("write error" )); - tmp_fd =fopen (tmp_file,"r" ); + tmp_fd =fopen (tmp_file,"r" UL_CLOEXECSTR );if (!tmp_fd)err (EXIT_FAILURE ,_ ("cannot open %s" ), tmp_file);if (fstat (fileno (tmp_fd), &end))
Signature · 1 line
2.15.1
PATCH 2/4 rename: use access(3) to check if a file exists
This is more lightweight than calling stat(3). In same go add a regression test to ensure changes like this will not break --no-overwrite option.
--- misc-utils/rename.c | 3 +-- tests/expected/rename/overwrite | 1 + tests/ts/rename/overwrite | 31 +++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 tests/expected/rename/overwrite create mode 100755 tests/ts/rename/overwrite
misc-utils/rename.c +1 -2
@@ -105,7 +105,6 @@ static int do_file(char *from, char *to, char *s, int verbose, int noact, int no {char *newname =NULL , *file=NULL ;int ret =1 ; -struct stat sb;if (strchr (from,'/' ) ==NULL &&strchr (to,'/' ) ==NULL ) file =strrchr (s,'/' );
@@ -113,7 +112,7 @@ static int do_file(char *from, char *to, char *s, int verbose, int noact, int no file = s;if (string_replace (from, to, file, s, &newname))return 0 ; -if (nooverwrite &&stat (newname, &sb) ==0 ) { +if (nooverwrite &&access (newname,F_OK ) ==0 ) {printf (_ ("Skipping existing file: `%s'\n" ), newname); ret =0 ; }
tests/expected/rename/overwrite new file +1 -0
@@ -0,0 +1 @@ +Skipping existing file: `rename_to'
tests/ts/rename/overwrite new file +31 -0
@@ -0,0 +1,31 @@ +#!/bin/bash + +# +# Copyright (C) 2017 Sami Kerola <[email protected]> +# +# This file is part of util-linux. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +TS_TOPDIR="${0%/*}/../.." +TS_DESC="overwrite" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_RENAME" +ts_cd "$TS_OUTDIR" + +touch rename_from rename_to +$TS_CMD_RENAME -v --no-overwrite from to rename_from > $TS_OUTPUT 2>&1 +rm rename_from rename_to >> $TS_OUTPUT 2>&1 + +ts_finalize
Signature · 1 line
2.15.1
Re: [PATCH 2/4] rename: use access(3) to check if a file exists
Quoted 3 lines · Sami Kerola
misc-utils/rename.c | 3 +-- tests/expected/rename/overwrite | 1 + tests/ts/rename/overwrite | 31 +++++++++++++++++++++++++++++++
Applied, thanks.
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
PATCH 3/4 docs: improve setarch(8) manual page
In reply to Sami KerolaAdd more information when and why one might want to use various options.
--- sys-utils/setarch.8 | 51 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 10 deletions(-)
sys-utils/setarch.8 +41 -10
@@ -1,4 +1,4 @@ -.TH SETARCH 8 "December 2014" "util-linux" "System Administration" +.TH SETARCH 8 "December 2017" "util-linux" "System Administration" .SH NAME setarch \- change reported architecture in new program environment and set personality flags .SH SYNOPSIS
@@ -30,41 +30,70 @@ can actually set each of these architectures depends on the running kernel. .TP .B \-\-uname\-2.6 Causes the \fIprogram\fR to see a kernel version number beginning with 2.6. +Turns on UNAME26. .TP .BR \-v , " \-\-verbose" Be verbose. .TP \fB\-3\fR, \fB\-\-3gb\fR -Specifies that processes should use a maximum of 3GB of address space on systems where it is supported (ADDR_LIMIT_3GB). +Specifies +.I program +should use a maximum of 3GB of address space. Supported on x86 (as of +2017-12-02). Turns on ADDR_LIMIT_3GB. .TP \fB\-\-4gb\fR -Ignored (for backward compatibility only). +Ignored for backward compatibility only. .TP \fB\-B\fR, \fB\-\-32bit\fR -Turns on ADDR_LIMIT_32BIT. +Limit the address space to 32 bits to emulate hardware. Supported on ARM +and Alpha (as of 2017-12-02). Turns on ADDR_LIMIT_32BIT. .TP \fB\-F\fR, \fB\-\-fdpic\-funcptrs\fR -Userspace function pointers point to descriptors (turns on FDPIC_FUNCPTRS). +User-space function pointers to signal handlers point. Use when kernel does +not have MMU. Supported on ARM, Blackfin, Fujitsu FR-V, and SuperH (as of +2017-12-02). Turns on FDPIC_FUNCPTRS. .TP \fB\-I\fR, \fB\-\-short\-inode\fR -Turns on SHORT_INODE. +Obsolete bug emulation flag. Turns on SHORT_INODE. .TP \fB\-L\fR, \fB\-\-addr\-compat\-layout\fR -Changes the way virtual memory is allocated (turns on the ADDR_COMPAT_LAYOUT). +Provide legacy virtual address space layout. Use when the +.I program +binary does not have PT_GNU_STACK ELF header. Turns on +ADDR_COMPAT_LAYOUT. .TP \fB\-R\fR, \fB\-\-addr\-no\-randomize\fR -Disables randomization of the virtual address space (turns on ADDR_NO_RANDOMIZE). +Disables randomization of the virtual address space. Turns on +ADDR_NO_RANDOMIZE. .TP \fB\-S\fR, \fB\-\-whole\-seconds\fR -Turns on WHOLE_SECONDS. +Obsolete bug emulation flag. Turns on WHOLE_SECONDS. .TP \fB\-T\fR, \fB\-\-sticky\-timeouts\fR +This makes +.BR select (2), +.BR pselect (2), +and +.BR ppoll (2) +system calls preserve the timeout value instead of storing the unslept time +when interrupted by a signal handler. Use when +.I program +depends on this behavior, and the source code is not available to be fixed. Turns on STICKY_TIMEOUTS. .TP \fB\-X\fR, \fB\-\-read\-implies\-exec\fR -Turns on READ_IMPLIES_EXEC. +If this is set then +.BR mmap (3) +PROT_READ will also add the PROT_EXEC bit - as expected by legacy x86 +binaries. Notice that the ELF loader will automatically set this bit when +it encounters a legacy binary. Turns on READ_IMPLIES_EXEC. .TP \fB\-Z\fR, \fB\-\-mmap\-page\-zero\fR +SVr4 bug emulation that will set +.BR mmap (3) +page zero as read-only. Use when +.I program +depends on this behavior, and the source code is not available to be fixed. Turns on MMAP_PAGE_ZERO. .TP .BR \-V , " \-\-version"
@@ -86,6 +115,8 @@ Elliot Lee .MT [email protected] Jindrich Novy .ME +.SH "SEE ALSO" +.BR personality (2) .SH AVAILABILITY The setarch command is part of the util-linux package and is available from .UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
Signature · 1 line
2.15.1
Re: [PATCH 3/4] docs: improve setarch(8) manual page
Quoted 11 lines · Sami Kerola
Add more information when and why one might want to use various options.
Signed-off-by Sami Kerola <[email protected]>--- sys-utils/setarch.8 | 51 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 10 deletions(-)sys-utils/setarch.8 +0
-0
[...]
sys-utils/setarch.8 can actually set each of these architectures depends on the running kernel. · line 45
Quoted 4 lines
.TP
\fB\-\-4gb\fRsys-utils/setarch.8 +1
-1-Ignored (for backward compatibility only). +Ignored for backward compatibility only.
The new wording is more confusing than the old one.
[...]
sys-utils/setarch.8 can actually set each of these architectures depends on the running kernel. · line 54
Quoted 6 lines
.TP
\fB\-F\fR, \fB\-\-fdpic\-funcptrs\fRsys-utils/setarch.8 +3
-1-Userspace function pointers point to descriptors (turns on FDPIC_FUNCPTRS). +User-space function pointers to signal handlers point. Use when kernel does +not have MMU. Supported on ARM, Blackfin, Fujitsu FR-V, and SuperH (as of +2017-12-02). Turns on FDPIC_FUNCPTRS.
The new wording is more confusing than the old one.
[...]
sys-utils/setarch.8 can actually set each of these architectures depends on the running kernel. · line 82
Quoted 12 lines
.TP
\fB\-T\fR, \fB\-\-sticky\-timeouts\fRsys-utils/setarch.8 +9
-0+This makes +.BR select (2), +.BR pselect (2), +and +.BR ppoll (2) +system calls preserve the timeout value instead of storing the unslept time +when interrupted by a signal handler. Use when +.I program +depends on this behavior, and the source code is not available to be fixed. Turns on STICKY_TIMEOUTS.
The use of word "fixed" is not appropriate here. According to select(2),
"On Linux, select() modifies timeout to reflect the amount of time not slept; most other implementations do not do this. (POSIX.1 permits either behavior.) This causes problems both when Linux code which reads timeout is ported to other operating systems, and when code is ported to Linux that reuses a struct timeval for multiple select()s in a loop without reinitializing it. Consider timeout to be undefined after select() returns."
Signature · 1 line
ldv
Karel Zak
maintainerRe: [PATCH 3/4] docs: improve setarch(8) manual page
In reply to Sami Kerolasys-utils/setarch.8 can actually set each of these architectures depends on the running kernel. · line 42
Quoted 6 lines · Sami Kerola
\fB\-3\fR, \fB\-\-3gb\fR
sys-utils/setarch.8 +4
-1-Specifies that processes should use a maximum of 3GB of address space on systems where it is supported (ADDR_LIMIT_3GB). +Specifies +.I program +should use a maximum of 3GB of address space. Supported on x86 (as of +2017-12-02). Turns on ADDR_LIMIT_3GB.
What is the magic day 2017-12-02 ?
Frankly, I don't like dates in docs. It's better to use versions "since util-linux v2.31" or "since Linux v4.32", etc.
sys-utils/setarch.8 can actually set each of these architectures depends on the running kernel. · line 45
Quoted 3 lines
\fB\-\-4gb\fR
sys-utils/setarch.8 +1
-1-Ignored (for backward compatibility only). +Ignored for backward compatibility only.
Dmitry is right, the old version is better.
sys-utils/setarch.8 can actually set each of these architectures depends on the running kernel. · line 81
Quoted 9 lines
sys-utils/setarch.8 +9
-0+This makes +.BR select (2), +.BR pselect (2), +and +.BR ppoll (2) +system calls preserve the timeout value instead of storing the unslept time +when interrupted by a signal handler. Use when +.I program +depends on this behavior, and the source code is not available to be fixed.
See Dmitry's note ;-)
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Re: [PATCH 3/4] docs: improve setarch(8) manual page
Quoted 10 lines · Karel Zak
sys-utils/setarch.8 can actually set each of these architectures depends on the running kernel. · line 42
Quoted 6 lines · Sami Kerola
\fB\-3\fR, \fB\-\-3gb\fR
sys-utils/setarch.8 +4
-1-Specifies that processes should use a maximum of 3GB of address space on systems where it is supported (ADDR_LIMIT_3GB). +Specifies +.I program +should use a maximum of 3GB of address space. Supported on x86 (as of +2017-12-02). Turns on ADDR_LIMIT_3GB.What is the magic day 2017-12-02 ?
Quoted 2 lines
Frankly, I don't like dates in docs. It's better to use versions "since util-linux v2.31" or "since Linux v4.32", etc.
Fair enough. I will figure out how to make this better.
Quoted 5 lines
sys-utils/setarch.8 can actually set each of these architectures depends on the running kernel. · line 45
Quoted 3 lines
\fB\-\-4gb\fR
sys-utils/setarch.8 +1
-1-Ignored (for backward compatibility only). +Ignored for backward compatibility only.Dmitry is right, the old version is better.
How about text:
This option is no-op compatibility with an old Debian setarch implementation. Please do not use.
Quoted 11 lines
sys-utils/setarch.8 can actually set each of these architectures depends on the running kernel. · line 81
Quoted 9 lines
sys-utils/setarch.8 +9
-0+This makes +.BR select (2), +.BR pselect (2), +and +.BR ppoll (2) +system calls preserve the timeout value instead of storing the unslept time +when interrupted by a signal handler. Use when +.I program +depends on this behavior, and the source code is not available to be fixed.See Dmitry's note ;-)
How about this:
-- snip
This makes
.BR select (2),
.BR pselect (2),
and
.BR ppoll (2)
system calls preserve the timeout value instead of storing the unslept time when interrupted by a signal handler. Use when
.I program
depends on this behavior. For more details see the timeout description from .BR select (2)
manual page. Turns on STICKY_TIMEOUTS.
-- snip
My remote git has the latest.
https://github.com/kerolasa/lelux-utiliteetit/blob/2017wk48/sys-utils/setarch.8
And that branch also has FIXME item near FDPIC_FUNCPTRS description. Proposal(s) welcome how to make that text understandable.
Signature · 2 lines
Sami Kerola http://www.iki.fi/kerolasa/
Re: [PATCH 3/4] docs: improve setarch(8) manual page
Quoted 2 lines · Sami Kerola
Quoted 1 line · Karel Zak
On Sun, Dec 03, 2017 at 12:51:16PM +0000, Sami Kerola wrote:
[...]
Quoted 10 lines
Quoted 5 lines
sys-utils/setarch.8 can actually set each of these architectures depends on the running kernel. · line 45
Quoted 3 lines
\fB\-\-4gb\fR
sys-utils/setarch.8 +1
-1-Ignored (for backward compatibility only). +Ignored for backward compatibility only.Dmitry is right, the old version is better.
How about text:
This option is no-op compatibility with an old Debian setarch implementation. Please do not use.
Let's add a description that is informative but without giving advice. For example,
"This option has no effect. It is retained for backward compatibility only, and may be removed in future releases."
or
"This option has no effect. It is retained for compatibility with ..., and may be removed in future releases."
Quoted 14 lines
Quoted 11 lines
sys-utils/setarch.8 can actually set each of these architectures depends on the running kernel. · line 81
Quoted 9 lines
sys-utils/setarch.8 +9
-0+This makes +.BR select (2), +.BR pselect (2), +and +.BR ppoll (2) +system calls preserve the timeout value instead of storing the unslept time +when interrupted by a signal handler. Use when +.I program +depends on this behavior, and the source code is not available to be fixed.See Dmitry's note ;-)
How about this:
Quoted 7 lines
-- snip
This makes
.BR select (2),
.BR pselect (2),
and
.BR ppoll (2)
system calls preserve the timeout value instead of storing the unslept time
I'm not sure about "unslept time" phrase. Wouldn't a more formal description be better, .e.g.
This makes
...
system calls preserve the timeout value instead of modifying it to reflect the amount of time not slept when interrupted by a signal handler.
...
Quoted 3 lines
when interrupted by a signal handler. Use when
.I program
depends on this behavior. For more details see the timeout description from
s/from/in/
Quoted 3 lines
.BR select (2)
manual page. Turns onSTICKY_TIMEOUTS.
-- snip
On the whole, this looks much better.
Quoted 6 lines
My remote git has the latest.
https://github.com/kerolasa/lelux-utiliteetit/blob/2017wk48/sys-utils/setarch.8
And that branch also has FIXME item near
FDPIC_FUNCPTRSdescription. Proposal(s) welcome how to make that text understandable.
What about this text:
"Treat user-space function pointers to signal handlers as pointers to address descriptors. This option has no effect on architectures that do not support FDPIC ELF binaries. Turns on FDPIC_FUNCPTRS."
Signature · 1 line
ldv
Re: [PATCH 3/4] docs: improve setarch(8) manual page
Quoted 12 lines · Dmitry V. Levin
Quoted 2 lines · Sami Kerola
Quoted 1 line · Karel Zak
On Sun, Dec 03, 2017 at 12:51:16PM +0000, Sami Kerola wrote:
[...]
Quoted 8 lines
Quoted 5 lines
sys-utils/setarch.8 can actually set each of these architectures depends on the running kernel. · line 45
Quoted 3 lines
\fB\-\-4gb\fR
sys-utils/setarch.8 +1
-1-Ignored (for backward compatibility only). +Ignored for backward compatibility only.Dmitry is right, the old version is better.
How about text:
Quoted 8 lines
Quoted 2 lines
This option is no-op compatibility with an old Debian setarch implementation. Please do not use.
Let's add a description that is informative but without giving advice. For example,
"This option has no effect. It is retained for backward compatibility only, and may be removed in future releases."
Hi Dmitry,
Your text is better. Added to most recent version of this change:
https://github.com/kerolasa/lelux-utiliteetit/commit/e9ebe4c52755edc736b2c440c8dc3b93678e69d1
Quoted 22 lines
Quoted 14 lines
Quoted 11 lines
sys-utils/setarch.8 can actually set each of these architectures depends on the running kernel. · line 81
Quoted 9 lines
sys-utils/setarch.8 +9
-0+This makes +.BR select (2), +.BR pselect (2), +and +.BR ppoll (2) +system calls preserve the timeout value instead of storing the unslept time +when interrupted by a signal handler. Use when +.I program +depends on this behavior, and the source code is not available to be fixed.See Dmitry's note ;-)
How about this:
Quoted 7 lines
-- snip
This makes
.BR select (2),
.BR pselect (2),
and
.BR ppoll (2)
system calls preserve the timeout value instead of storing the unslept time
Quoted 8 lines
I'm not sure about "unslept time" phrase. Wouldn't a more formal description be better, .e.g.
This makes
...
system calls preserve the timeout value instead of modifying it to reflect the amount of time not slept when interrupted by a signal handler.
...
That is better. Used in the most recent update.
Quoted 5 lines
Quoted 3 lines
when interrupted by a signal handler. Use when
.I program
depends on this behavior. For more details see the timeout description froms/from/in/
Fixed.
Quoted 10 lines
Quoted 3 lines
.BR select (2)
manual page. Turns onSTICKY_TIMEOUTS.
-- snipOn the whole, this looks much better.
Quoted 4 lines
My remote git has the latest.
https://github.com/kerolasa/lelux-utiliteetit/blob/2017wk48/sys-utils/setarch.8
Quoted 8 lines
Quoted 2 lines
And that branch also has FIXME item near
FDPIC_FUNCPTRSdescription. Proposal(s) welcome how to make that text understandable.What about this text:
"Treat user-space function pointers to signal handlers as pointers to address descriptors. This option has no effect on architectures that do not support FDPIC ELF binaries. Turns on
FDPIC_FUNCPTRS."
Used almost as-is. I included list of architectures that are expected to work with a recent kernel version.
If no further objections. Karel could you have final review and merge from my remote branch 2017wk48.
Signature · 2 lines
Sami Kerola http://www.iki.fi/kerolasa/
Re: [PATCH 3/4] docs: improve setarch(8) manual page
Quoted 2 lines
If no further objections. Karel could you have final review and merge from my remote branch 2017wk48.
Merged, thanks!
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Karel Zak
maintainerRe: [PATCH 3/4] docs: improve setarch(8) manual page
In reply to Dmitry V. LevinQuoted 10 lines · Dmitry V. Levin
Quoted 2 lines · Sami Kerola
Quoted 1 line · Karel Zak
On Sun, Dec 03, 2017 at 12:51:16PM +0000, Sami Kerola wrote:
[...]
Quoted 6 lines
Quoted 5 lines
sys-utils/setarch.8 can actually set each of these architectures depends on the running kernel. · line 45
Quoted 3 lines
\fB\-\-4gb\fR
sys-utils/setarch.8 +1
-1-Ignored (for backward compatibility only). +Ignored for backward compatibility only.Dmitry is right, the old version is better.
Quoted 6 lines
Quoted 4 lines
How about text:
This option is no-op compatibility with an old Debian setarch implementation. Please do not use.
Let's add a description that is informative but without giving advice.
Yes, and without any distro name...
Quoted 4 lines
For example,
"This option has no effect. It is retained for backward compatibility only, and may be removed in future releases."
+1
Quoted 10 lines
Quoted 9 lines
How about this:
-- snip
This makes
.BR select (2),
.BR pselect (2),
and
.BR ppoll (2)
system calls preserve the timeout value instead of storing the unslept time
Quoted 8 lines
I'm not sure about "unslept time" phrase. Wouldn't a more formal description be better, .e.g.
This makes
...
system calls preserve the timeout value instead of modifying it to reflect the amount of time not slept when interrupted by a signal handler.
...
+1
Quoted 17 lines
Quoted 4 lines
when interrupted by a signal handler. Use when
.I program
depends on this behavior. For more details see the timeout description froms/from/in/
Quoted 3 lines
.BR select (2)
manual page. Turns onSTICKY_TIMEOUTS.
-- snipOn the whole, this looks much better.
Quoted 4 lines
My remote git has the latest.
https://github.com/kerolasa/lelux-utiliteetit/blob/2017wk48/sys-utils/setarch.8
Quoted 8 lines
Quoted 2 lines
And that branch also has FIXME item near
FDPIC_FUNCPTRSdescription. Proposal(s) welcome how to make that text understandable.What about this text:
"Treat user-space function pointers to signal handlers as pointers to address descriptors. This option has no effect on architectures that do not support FDPIC ELF binaries. Turns on
FDPIC_FUNCPTRS."
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
PATCH 4/4 setarch: minor code clean up
In reply to Sami KerolaRemove global variable, skip unnecessary comparison, and remove version printing function when a simple printf() can do the job. In same go fix compiler warning.
sys-utils/setarch.c:296:4: warning: null argument where non-null required (argument 2) [-Wnonnull]
execl("/bin/bash", NULL);--- sys-utils/setarch.c | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-)
sys-utils/setarch.c +15 -23
@@ -82,9 +82,8 @@# define ADDR_LIMIT_3GB 0x8000000#endif -static int archwrapper; -static void __attribute__((__noreturn__))usage (void ) +static void __attribute__((__noreturn__))usage (int archwrapper) {fputs (USAGE_HEADER , stdout);if (!archwrapper)
@@ -120,13 +119,6 @@ static void __attribute__((__noreturn__)) usage(void)exit (EXIT_SUCCESS ); } -static void __attribute__((__noreturn__)) -show_version (void ) -{ -printf (UTIL_LINUX_VERSION ); -exit (EXIT_SUCCESS ); -} -static int set_arch (const char *pers,unsigned long options,int list) {struct utsname un;
@@ -253,6 +245,7 @@ int main(int argc, char *argv[])const char *arch =NULL ;unsigned long options =0 ;int verbose =0 ; +int archwrapper;int c;/* Options without equivalent short options */
@@ -294,9 +287,17 @@ int main(int argc, char *argv[])errtryhelp (EXIT_FAILURE ); } archwrapper =strcmp (program_invocation_short_name,"setarch" ) !=0 ; -if (archwrapper) +if (archwrapper) { arch = program_invocation_short_name;/* symlinks to setarch */ -else { +#if defined(__sparc64__) || defined(__sparc__) +if (strcmp (arch,"sparc32bash" ) ==0 ) { +if (set_arch (arch,0L ,0 )) +err (EXIT_FAILURE ,_ ("Failed to set personality to %s" ), arch); +execl ("/bin/bash" ,"" ,NULL ); +err (EXIT_FAILURE ,_ ("failed to execute %s" ),"/bin/bash" ); + } +#endif + }else {if (1 < argc && *argv[1 ] !='-' ) { arch = argv[1 ]; argv[1 ] = argv[0 ];/* for getopt_long() to get the program name */
@@ -305,23 +306,14 @@ int main(int argc, char *argv[]) } } -#if defined(__sparc64__) || defined(__sparc__) -if (archwrapper &&strcmp (arch,"sparc32bash" ) ==0 ) { -if (set_arch (arch,0L ,0 )) -err (EXIT_FAILURE ,_ ("Failed to set personality to %s" ), arch); -execl ("/bin/bash" ,NULL ); -err (EXIT_FAILURE ,_ ("failed to execute %s" ),"/bin/bash" ); - } -#endif -while ((c =getopt_long (argc, argv,"+hVv3BFILRSTXZ" , longopts,NULL )) !=-1 ) {switch (c) {case 'h' : -usage (); +usage (archwrapper);break ;case 'V' : -show_version (); -break ; +printf (UTIL_LINUX_VERSION ); +return EXIT_SUCCESS ;case 'v' : verbose =1 ;break ;
Signature · 1 line
2.15.1
Re: [PATCH 4/4] setarch: minor code clean up
Quoted 2 lines · Sami Kerola
sys-utils/setarch.c | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-)
Applied, thanks.
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Quoted 2 lines · Sami Kerola
login-utils/vipw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Applied, thanks.
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com