Bug 27258 - getty(8) didn't check if if= isn't empty
Summary: getty(8) didn't check if if= isn't empty
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 4.3-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-05-10 23:00 UTC by Cyrille Lefevre
Modified: 2017-12-31 22:36 UTC (History)
0 users

See Also:


Attachments
file.diff (497 bytes, patch)
2001-05-10 23:00 UTC, Cyrille Lefevre
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cyrille Lefevre 2001-05-10 23:00:00 UTC
	
	all is in the subject. this is not so important, but be safe.

How-To-Repeat: 
	:if=: in gettytab
Comment 1 Bruce Evans 2001-05-11 08:43:22 UTC
On Thu, 10 May 2001, Cyrille Lefevre wrote:

> >Description:
> 	
> 	all is in the subject. this is not so important, but be safe.
> 
> >How-To-Repeat:
> 
> 	:if=: in gettytab
> 
> >Fix:
> 
> Index: main.c
> ===================================================================
> RCS file: /home/ncvs/src/libexec/getty/main.c,v
> retrieving revision 1.28.2.2
> diff -u -r1.28.2.2 main.c
> --- main.c	2001/03/05 11:17:08	1.28.2.2
> +++ main.c	2001/03/11 06:02:46
> @@ -324,7 +324,7 @@
>  
>  		/* if this is the first time through this, and an
>  		   issue file has been given, then send it */
> -		if (first_time && IF) {
> +		if (first_time && IF && *IF) {
>  			int fd;
>  
>  			if ((fd = open(IF, O_RDONLY)) != -1) {

This is safer than `:if=/bin/sh:'.  It just causes the open to fail
just like for any other nonexistent file (POSIX standard).

Bruce
Comment 2 clefevre-lists 2001-05-14 02:36:16 UTC
Bruce Evans <bde@zeta.org.au> writes:

[snip]
> > -		if (first_time && IF) {
> > +		if (first_time && IF && *IF) {
> >  			int fd;
> >  
> >  			if ((fd = open(IF, O_RDONLY)) != -1) {
> 
> This is safer than `:if=/bin/sh:'.  It just causes the open to fail
> just like for any other nonexistent file (POSIX standard).

yes, but this syscall isn't needed, so, why not to get rid of it if
if= is empty ?

Cyrille.
--
home: mailto:clefevre@poboxes.com   UNIX is user-friendly; it's just particular
work: mailto:Cyrille.Lefevre@edf.fr   about who it chooses to be friends with.
Comment 3 Bruce Evans 2001-05-14 10:01:55 UTC
On 14 May 2001, Cyrille Lefevre wrote:

> Bruce Evans <bde@zeta.org.au> writes:
> 
> [snip]
> > > -		if (first_time && IF) {
> > > +		if (first_time && IF && *IF) {
> > >  			int fd;
> > >  
> > >  			if ((fd = open(IF, O_RDONLY)) != -1) {
> > 
> > This is safer than `:if=/bin/sh:'.  It just causes the open to fail
> > just like for any other nonexistent file (POSIX standard).
> 
> yes, but this syscall isn't needed, so, why not to get rid of it if
> if= is empty ?

It takes more code, and takes longer in the usual case.

Bruce
Comment 4 clefevre-lists 2001-05-15 01:32:11 UTC
Bruce Evans <bde@zeta.org.au> writes:

> On 14 May 2001, Cyrille Lefevre wrote:
> 
> > Bruce Evans <bde@zeta.org.au> writes:
> > 
> > [snip]
> > > > -		if (first_time && IF) {
> > > > +		if (first_time && IF && *IF) {
> > > >  			int fd;
> > > >  
> > > >  			if ((fd = open(IF, O_RDONLY)) != -1) {
> > > 
> > > This is safer than `:if=/bin/sh:'.  It just causes the open to fail
> > > just like for any other nonexistent file (POSIX standard).
> > 
> > yes, but this syscall isn't needed, so, why not to get rid of it if
> > if= is empty ?
> 
> It takes more code, and takes longer in the usual case.

are you joking ? a syscall faster than a simple test like this ?

Cyrille.
--
home: mailto:clefevre@poboxes.com   UNIX is user-friendly; it's just particular
work: mailto:Cyrille.Lefevre@edf.fr   about who it chooses to be friends with.
Comment 5 Bruce Evans 2001-05-15 10:35:36 UTC
On 15 May 2001, Cyrille Lefevre wrote:

> Bruce Evans <bde@zeta.org.au> writes:
> 
> > On 14 May 2001, Cyrille Lefevre wrote:
> > 
> > > Bruce Evans <bde@zeta.org.au> writes:
> > > 
> > > [snip]
> > > > > -		if (first_time && IF) {
> > > > > +		if (first_time && IF && *IF) {
> > > > >  			int fd;
> > > > >  
> > > > >  			if ((fd = open(IF, O_RDONLY)) != -1) {
> > > > 
> > > > This is safer than `:if=/bin/sh:'.  It just causes the open to fail
> > > > just like for any other nonexistent file (POSIX standard).
> > > 
> > > yes, but this syscall isn't needed, so, why not to get rid of it if
> > > if= is empty ?
> > 
> > It takes more code, and takes longer in the usual case.
> 
> are you joking ? a syscall faster than a simple test like this ?

No.  The null test is faster than a simple test.

Bruce
Comment 6 Cyrille Lefevre 2004-03-04 15:24:01 UTC
anyone to commit this PR which is a one line patch !

thanks in advance.

Cyrille Lefevre.
-- 
home: mailto:cyrille.lefevre@laposte.net
Comment 7 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:46 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped