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; --> Otto Moerbeek wrote: > This angel has problem with KNF: Ow yes: int\nmain(... > space between function name and ...


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, 08:49 AM
Han Boetes
 
Posts: n/a
Default Re: Shouldn't /sbin/nologin send the message to stderr?

Otto Moerbeek wrote:
> This angel has problem with KNF:


Ow yes: int\nmain(...


> space between function name and arg list. Also, return (expr);
> is preferred to return expr;


It strikes me as inconsistent. I'd expect either ``return 0;'' or
``return(0)'' but not ``return (0)''. Any pointer to the reason
behind this? I can't find it in style(9).


> Apart from that, formatting changes combined with functional
> changes are frowned upon.


Errr OK, I'll keep it in mind.


> But the main point: you did not make clear why stderr would be
> better.


Because it's an errormessage. Errormessages should be sent to
stderr. I tried login in to a disabled account to see if the
errormessage was not echoed but that was also not the case. That
why I was informing if there were any other objections to sending
the message to stderr. It was not a rhetorical question, nor was
my patch a suggestion nor a recommendation. It was merely meant to
clarify what I had in mind.

But now after taking your remarks in account, this is what the
code should look like in the end. After applying one patch for the
functional change and one for the format. (without the license for
briefness):

[snip: licensenote]
#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

/* Distinctly different from _PATH_NOLOGIN. */
#define _PATH_NOLOGIN_TXT "/etc/nologin.txt"

#define DEFAULT_MESG "This account is currently not available.\n"

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

nfd = open(_PATH_NOLOGIN_TXT, O_RDONLY);
if (nfd == -1) {
write(STDERR_FILENO, DEFAULT_MESG, strlen(DEFAULT_MESG));
return (1);
}

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

close(nfd);
return (1);
}

What say you?



# Han

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 06:59 AM.


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