3 * $Id: banned.c,v 1.2 1999/04/21 09:07:55 mdw Exp $
5 * Ban a user from logging in
7 * (c) 1999 Mark Wooding
10 /*----- Licensing notice --------------------------------------------------*
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software Foundation,
24 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 /*----- Revision history --------------------------------------------------*
30 * Revision 1.2 1999/04/21 09:07:55 mdw
31 * Fiddle with copyright messages so that they're correct.
33 * Revision 1.1.1.1 1999/04/20 00:19:04 mdw
38 /*----- Header files ------------------------------------------------------*/
44 #include <sys/types.h>
50 /*----- Main code ---------------------------------------------------------*/
52 static const char *quis
= "banned";
54 int main(int argc
, char *argv
[])
61 /* --- Resolve the program name --- */
66 for (q
= argv
[0]; *q
; q
++) {
73 /* --- Read the user's name --- */
75 pw
= getpwuid(getuid());
77 fprintf(stderr
, "%s: you don't exist. Go away.\n", quis
);
81 /* --- Open the log file --- */
83 openlog(quis
, 0, LOG_AUTH
);
84 syslog(LOG_CRIT
, "banned user `%s' attempted to log in", pw
->pw_name
);
86 /* --- Change directory to the user's home --- */
88 if (chdir(pw
->pw_dir
) < 0) {
89 fprintf(stderr
, "%s: couldn't change directory: %s\n",
90 quis
, strerror(errno
));
94 /* --- Open the reason file --- */
96 if ((fd
= open(".banned", O_RDONLY
)) < 0) {
97 fprintf(stderr
, "%s: couldn't open `.banned' file: %s\n",
98 quis
, strerror(errno
));
102 /* --- Dump the reason information out --- */
105 r
= read(fd
, buf
, sizeof(buf
));
109 fprintf(stderr
, "%s: couldn't read: %s\n", quis
, strerror(errno
));
112 write(STDOUT_FILENO
, buf
, r
);
118 return (EXIT_FAILURE
);
121 /*----- That's all, folks -------------------------------------------------*/