char debug_enabled=0;
char *myname;
pid_t mypid;
+int err = 0;
NSS_STATUS winbindd_request(int req_type,
struct winbindd_request *request,
return; /* useless */
}
+static void
+usage(char *program)
+{
+ fprintf(stderr,"Usage: %s [-d] [-h]\n"
+ " -d enable debugging\n"
+ " -h this message\n",
+ program);
+}
void
process_options(int argc, char *argv[])
{
int opt;
- while (-1 != (opt = getopt(argc, argv, "d"))) {
+ opterr = 0;
+ while (-1 != (opt = getopt(argc, argv, "dh"))) {
switch (opt) {
case 'd':
debug_enabled = 1;
break;
+ case 'h':
+ usage(argv[0]);
+ exit(0);
+ case '?':
+ opt = optopt;
+ /* fall thru to default */
default:
- warn("Unknown option: -%c. Exiting\n", opt);
+ warn("Unknown option: -%c\n\n", opt);
+ usage(argv[0]);
exit(1);
break; /* not reached */
}
return;
}
-
void manage_request(void)
{
char buf[BUFFER_SIZE+1];
c=memchr(buf,'\n',BUFFER_SIZE);
if (c) {
- *c='\0';
- length=c-buf;
+ *c = '\0';
+ length = c-buf;
} else {
- warn("No newline in '%s'. Dying.\n",buf);
- exit(1);
+ err = 1;
+ return;
+ }
+ if (err) {
+ warn("Oversized message\n");
+ SEND("ERR");
+ err = 0;
+ return;
}
debug("Got '%s' from squid (length: %d).\n",buf,length);
+
+ if (buf[0] == '\0') {
+ warn("Invalid Request\n");
+ SEND("ERR");
+ return;
+ }
+
user=buf;
pass=memchr(buf,' ',length);
/* the attempted entropy source. If it doesn't exist, random() is uesed */
#define ENTROPY_SOURCE "/dev/urandom"
-#define DOMAIN "GCSINT" /* TODO: fix ntlm_make_challenge */
-
/************* END CONFIGURATION *************/
/* Debugging stuff */
/*
- * $Id: wb_check_group.c,v 1.2 2002/07/07 21:36:58 hno Exp $
+ * $Id: wb_check_group.c,v 1.3 2002/07/20 11:26:20 hno Exp $
*
* This is a helper for the external ACL interface for Squid Cache
* Copyright (C) 2002 Guido Serassio <squidnt@serassio.it>
return match;
}
+static void
+usage(char *program)
+{
+ fprintf(stderr,"Usage: %s [-d] [-h]\n"
+ " -d enable debugging\n"
+ " -h this message\n",
+ program);
+}
+
void
process_options(int argc, char *argv[])
{
int opt;
- while (-1 != (opt = getopt(argc, argv, "d"))) {
+ opterr = 0;
+ while (-1 != (opt = getopt(argc, argv, "dh"))) {
switch (opt) {
case 'd':
debug_enabled = 1;
break;
+ case 'h':
+ usage(argv[0]);
+ exit(0);
+ case '?':
+ opt = optopt;
+ /* fall thru to default */
default:
- warn("Unknown option: -%c. Exiting\n", opt);
+ warn("Unknown option: -%c\n\n", opt);
+ usage(argv[0]);
exit(1);
break; /* not reached */
}
char buf[BUFSIZE];
char *username;
char *group;
+ int err = 0;
if (argc > 0) { /* should always be true */
myname=strrchr(argv[0],'/');
/* Main Loop */
while (fgets (buf, BUFSIZE, stdin))
{
-
+ if (NULL == strchr(buf, '\n')) {
+ err = 1;
+ continue;
+ }
+ if (err) {
+ warn("Oversized message\n");
+ goto error;
+ }
+
if ((p = strchr(buf, '\n')) != NULL)
*p = '\0'; /* strip \n */
if ((p = strchr(buf, '\r')) != NULL)
*p = '\0'; /* strip \r */
debug("Got '%s' from Squid (length: %d).\n",buf,sizeof(buf));
-
+
+ if (buf[0] == '\0') {
+ warn("Invalid Request\n");
+ goto error;
+ }
+
username = strwordtok(buf, &t);
group = strwordtok(NULL, &t);
if (Valid_Group(username, group)) {
printf ("OK\n");
} else {
+error:
printf ("ERR\n");
}
+ err = 0;
}
return 0;
}
*/
/*
* TODO:
- * -add handling of the -d flag
* -move all squid-helper-protocol-related operations to helper functions
- * -remove the hard-coded target NT domain name
*
* - MAYBE move squid-helper-protocol-related opetations to an external
* library?
{
fprintf(stderr,"Usage: %s [-d] [-h] [domain]\n"
" -d enable debugging\n"
- " -hi this message\n"
+ " -h this message\n"
" domain target domain, if different from the winbind configuration\n",
program);
}
int opt;
char *target_domain = NULL;
+ opterr = 0;
while (-1 != (opt = getopt(argc, argv, "dh"))) {
switch (opt) {
case 'd':
case 'h':
usage(argv[0]);
exit(0);
+ case '?':
+ opt = optopt;
+ /* fall thru to default */
default:
warn("Unknown option: -%c\n\n", opt);
usage(argv[0]);