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 /*----- Header files ------------------------------------------------------*/
33 #include <sys/types.h>
39 /*----- Main code ---------------------------------------------------------*/
41 static const char *quis
= "banned";
43 int main(int argc
, char *argv
[])
50 /* --- Resolve the program name --- */
55 for (q
= argv
[0]; *q
; q
++) {
62 /* --- Read the user's name --- */
64 pw
= getpwuid(getuid());
66 fprintf(stderr
, "%s: you don't exist. Go away.\n", quis
);
70 /* --- Open the log file --- */
72 openlog(quis
, 0, LOG_AUTH
);
73 syslog(LOG_CRIT
, "banned user `%s' attempted to log in", pw
->pw_name
);
75 /* --- Change directory to the user's home --- */
77 if (chdir(pw
->pw_dir
) < 0) {
78 fprintf(stderr
, "%s: couldn't change directory: %s\n",
79 quis
, strerror(errno
));
83 /* --- Open the reason file --- */
85 if ((fd
= open(".banned", O_RDONLY
)) < 0) {
86 fprintf(stderr
, "%s: couldn't open `.banned' file: %s\n",
87 quis
, strerror(errno
));
91 /* --- Dump the reason information out --- */
94 r
= read(fd
, buf
, sizeof(buf
));
98 fprintf(stderr
, "%s: couldn't read: %s\n", quis
, strerror(errno
));
101 write(STDOUT_FILENO
, buf
, r
);
107 return (EXIT_FAILURE
);
110 /*----- That's all, folks -------------------------------------------------*/