Unix Technical Forum

Re: Shouldn't /sbin/nologin send the message to stderr?

This is a discussion on Re: Shouldn't /sbin/nologin send the message to stderr? within the mailing.openbsd.tech forums, part of the OpenBSD category; --> Alright. Then it all boils down to those two patches: The first is the functional changes, second is for ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > mailing.openbsd.tech

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-18-2008, 07:49 AM
Han Boetes
 
Posts: n/a
Default Re: Shouldn't /sbin/nologin send the message to stderr?

Alright. Then it all boils down to those two patches: The first is
the functional changes, second is for the layout.


Index: nologin.c
================================================== =================
RCS file: /cvs/src/sbin/nologin/nologin.c,v
retrieving revision 1.5
diff -u -p -r1.5 nologin.c
--- nologin.c 10 Jul 2003 00:00:58 -0000 1.5
+++ nologin.c 13 May 2005 13:26:19 -0000
@@ -28,7 +28,6 @@
#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include <unistd.h>

@@ -45,14 +44,14 @@ int main(int argc, char *argv[])
char nbuf[BUFSIZ];

nfd = open(_PATH_NOLOGIN_TXT, O_RDONLY);
- if (nfd < 0) {
+ if (nfd == -1) {
write(STDOUT_FILENO, DEFAULT_MESG, strlen(DEFAULT_MESG));
- exit (1);
+ return (1);
}

while ((nrd = read(nfd, nbuf, sizeof(nbuf))) != -1 && nrd != 0)
write(STDOUT_FILENO, nbuf, nrd);
close (nfd);

- exit (1);
+ return (1);
}


--- nologin.c Fri May 13 15:29:02 2005
+++ nologin.c.bak Fri May 13 15:30:02 2005
@@ -37,11 +37,12 @@
#define DEFAULT_MESG "This account is currently not available.\n"

/*ARGSUSED*/
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
- int nfd;
- ssize_t nrd;
- char nbuf[BUFSIZ];
+ int nfd;
+ ssize_t nrd;
+ char nbuf[BUFSIZ];

nfd = open(_PATH_NOLOGIN_TXT, O_RDONLY);
if (nfd == -1) {
@@ -51,7 +52,7 @@

while ((nrd = read(nfd, nbuf, sizeof(nbuf))) != -1 && nrd != 0)
write(STDOUT_FILENO, nbuf, nrd);
- close (nfd);

+ close(nfd);
return (1);
}




# Han
--
( homepage : http://www.xs4all.nl/~hanb _______
)) pgpkey : http://www.xs4all.nl/~hanb/keys/Han_pubkey.gpg > ====<--.
C|~~| email : h a n @ m i j n c o m p u t e r . n l | = |-'
`--' irc : irc.freenode.net#UnixNL `------'

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:29 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com