From cff01c538f3647f5169a8e5a3ab4b77ad0cebce5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 28 Apr 2003 17:14:49 +0000 Subject: Add example authentication module (This used to be commit e112dc1641c47c7185e098918980df1a4d950bd7) --- examples/auth/Makefile | 31 +++++++++++++++++++++++++ examples/auth/auth_skel.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 examples/auth/Makefile create mode 100644 examples/auth/auth_skel.c (limited to 'examples/auth') diff --git a/examples/auth/Makefile b/examples/auth/Makefile new file mode 100644 index 0000000000..dac28fdd40 --- /dev/null +++ b/examples/auth/Makefile @@ -0,0 +1,31 @@ +# Makefile for samba-pdb examples +# Variables + +CC = gcc +LIBTOOL = libtool + +SAMBA_SRC = ../../source +SAMBA_INCL = ../../source/include +UBIQX_SRC = ../../source/ubiqx +SMBWR_SRC = ../../source/smbwrapper +CFLAGS = -I$(SAMBA_SRC) -I$(SAMBA_INCL) -I$(UBIQX_SRC) -I$(SMBWR_SRC) -Wall -g +AUTH_OBJS = auth_skel.so + +# Default target + +default: $(AUTH_OBJS) + +# Pattern rules + +%.so: %.lo + $(LIBTOOL) $(CC) -shared -o $@ $< $(LDFLAGS) + +%.lo: %.c + $(LIBTOOL) $(CC) $(CPPFLAGS) $(CFLAGS) -c $< + +# Misc targets + +clean: + rm -rf .libs + rm -f core *~ *% *.bak \ + $(AUTH_OBJS) $(AUTH_OBJS:.so=.o) $(AUTH_OBJS:.so=.lo) diff --git a/examples/auth/auth_skel.c b/examples/auth/auth_skel.c new file mode 100644 index 0000000000..bcc3bdd96a --- /dev/null +++ b/examples/auth/auth_skel.c @@ -0,0 +1,59 @@ +/* + Unix SMB/CIFS implementation. + Password and authentication handling + Copyright (C) Andrew Bartlett 2001 + Copyright (C) Jelmer Vernooij 2003 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_AUTH + +static NTSTATUS check_skel_security(const struct auth_context *auth_context, + void *my_private_data, + TALLOC_CTX *mem_ctx, + const auth_usersupplied_info *user_info, + auth_serversupplied_info **server_info) +{ + if (!user_info || !auth_context) { + return NT_STATUS_LOGON_FAILURE; + } + + /* Insert your authentication checking code here, + * and return NT_STATUS_OK if authentication succeeds */ + + /* For now, just refuse all connections */ + return NT_STATUS_LOGON_FAILURE; +} + +/* module initialisation */ +NTSTATUS auth_init_skel(struct auth_context *auth_context, const char *param, auth_methods **auth_method) +{ + if (!make_auth_methods(auth_context, auth_method)) { + return NT_STATUS_NO_MEMORY; + } + + (*auth_method)->auth = check_skel_security; + (*auth_method)->name = "skel"; + return NT_STATUS_OK; +} + +NTSTATUS init_module(void) +{ + return smb_register_auth(AUTH_INTERFACE_VERSION, "skel", auth_init_skel); +} -- cgit From 410a6c72eafbb7fb1ecc9bf89310842ea8027494 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 14 Sep 2004 00:21:11 +0000 Subject: r2331: check password script code and example from trunk (This used to be commit f836be323a233f3a28cbaa04c532e83ea98ead89) --- examples/auth/crackcheck/Makefile | 25 ++++++++++++++ examples/auth/crackcheck/crackcheck.c | 62 +++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 examples/auth/crackcheck/Makefile create mode 100644 examples/auth/crackcheck/crackcheck.c (limited to 'examples/auth') diff --git a/examples/auth/crackcheck/Makefile b/examples/auth/crackcheck/Makefile new file mode 100644 index 0000000000..84377aafef --- /dev/null +++ b/examples/auth/crackcheck/Makefile @@ -0,0 +1,25 @@ +# C compiler +#CC=cc +CC=gcc + +# Uncomment the following to add symbols to the code for debugging +#DEBUG=-g -Wall + +# Optimization for the compiler +#OPTIMIZE= +OPTIMIZE=-O2 + +CFLAGS= $(DEBUG) $(OPTIMIZE) + +OBJS = crackcheck.o +LIBS = -lcrack + +crackcheck: $(OBJS) + $(CC) $(CFLAGS) $(LIBS) -o crackcheck $(OBJS) + +clean: + rm -f core *.o crackcheck + +install: crackcheck + install -m 555 crackcheck $(PREFIX)/sbin/crackcheck + diff --git a/examples/auth/crackcheck/crackcheck.c b/examples/auth/crackcheck/crackcheck.c new file mode 100644 index 0000000000..338433779b --- /dev/null +++ b/examples/auth/crackcheck/crackcheck.c @@ -0,0 +1,62 @@ +#include +#include +#include +#include +#include +#include + +void usage(char *command) { + char *c, *comm; + + comm = command; + while ((c = strrchr(comm, '/')) != NULL) { + comm = c + 1; + } + + fprintf(stderr, "Usage: %s -d dictionary\n\n", comm); + fprintf(stderr, " -d dictionary file for cracklib\n\n"); + fprintf(stderr, " The password is expected to be given via stdin.\n\n"); + exit(-1); +} + +int main(int argc, char **argv) { + extern char *optarg; + int c; + + char f[256]; + char *dictionary = NULL; + char *password; + char *reply; + + while ( (c = getopt(argc, argv, "d:")) != EOF){ + switch(c) { + case 'd': + dictionary = strdup(optarg); + break; + default: + usage(argv[0]); + } + } + + if (dictionary == NULL) { + fprintf(stderr, "ERR - Wrong Command Line\n\n"); + usage(argv[0]); + } + + password = fgets(f, sizeof(f), stdin); + + if (password == NULL) { + fprintf(stderr, "ERR - Failed to read password\n\n"); + exit(-2); + } + + reply = FascistCheck(password, dictionary); + if (reply != NULL) { + fprintf(stderr, "ERR - %s\n\n", reply); + exit(-3); + } + + exit(0); + +} + -- cgit From de72d898778635af20a1f6a394fe6c837e2ed149 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 23 Sep 2004 18:11:08 +0000 Subject: r2567: Patches from Lars Mueller : trivial fix for autoconf and autoheader versions with a letter in the version string. This happens in our current beta named distribution tree. trivial patch to fix the build with the upcoming libtool version. It will be mandatory to use --mode while using libtool. (This used to be commit 80d591f8cc62d513eb99112e6533b93ee901d27d) --- examples/auth/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples/auth') diff --git a/examples/auth/Makefile b/examples/auth/Makefile index dac28fdd40..21d18de075 100644 --- a/examples/auth/Makefile +++ b/examples/auth/Makefile @@ -18,10 +18,10 @@ default: $(AUTH_OBJS) # Pattern rules %.so: %.lo - $(LIBTOOL) $(CC) -shared -o $@ $< $(LDFLAGS) + $(LIBTOOL) --mode=link $(CC) -shared -o $@ $< $(LDFLAGS) %.lo: %.c - $(LIBTOOL) $(CC) $(CPPFLAGS) $(CFLAGS) -c $< + $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(CFLAGS) -c $< # Misc targets -- cgit From 2eab58d3fdaef69eef4958f11b4dec730ae18372 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 30 Jan 2005 22:47:26 +0000 Subject: r5112: Fix for shared object creation in examples. Bugzilla #2058. (This used to be commit 8e5db6f08ceb969bd2580558031f3737b32f10b1) --- examples/auth/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'examples/auth') diff --git a/examples/auth/Makefile b/examples/auth/Makefile index 21d18de075..d6dbc28f40 100644 --- a/examples/auth/Makefile +++ b/examples/auth/Makefile @@ -9,7 +9,7 @@ SAMBA_INCL = ../../source/include UBIQX_SRC = ../../source/ubiqx SMBWR_SRC = ../../source/smbwrapper CFLAGS = -I$(SAMBA_SRC) -I$(SAMBA_INCL) -I$(UBIQX_SRC) -I$(SMBWR_SRC) -Wall -g -AUTH_OBJS = auth_skel.so +AUTH_OBJS = auth_skel.la # Default target @@ -17,8 +17,8 @@ default: $(AUTH_OBJS) # Pattern rules -%.so: %.lo - $(LIBTOOL) --mode=link $(CC) -shared -o $@ $< $(LDFLAGS) +%.la: %.lo + $(LIBTOOL) --mode=link $(CC) -module -o $@ $< $(LDFLAGS) %.lo: %.c $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(CFLAGS) -c $< @@ -28,4 +28,4 @@ default: $(AUTH_OBJS) clean: rm -rf .libs rm -f core *~ *% *.bak \ - $(AUTH_OBJS) $(AUTH_OBJS:.so=.o) $(AUTH_OBJS:.so=.lo) + $(AUTH_OBJS) $(AUTH_OBJS:.la=.o) $(AUTH_OBJS:.la=.lo) -- cgit From b7eec4e85693deedf14908cf909e39a2167558eb Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 26 Dec 2005 17:22:46 +0000 Subject: r12495: Crackcheck utility enhancement based on patch sent by Tom Geissler (This used to be commit aa34304f61bd10cb1f80b4c0c27dd3834dc47fa3) --- examples/auth/crackcheck/crackcheck.c | 73 ++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) (limited to 'examples/auth') diff --git a/examples/auth/crackcheck/crackcheck.c b/examples/auth/crackcheck/crackcheck.c index 338433779b..0636114a17 100644 --- a/examples/auth/crackcheck/crackcheck.c +++ b/examples/auth/crackcheck/crackcheck.c @@ -19,20 +19,81 @@ void usage(char *command) { exit(-1); } +int complexity(char* passwd) +{ + /* TG 26.10.2005 + * check password for complexity like MS Windows NT + */ + + int c_upper = 0; + int c_lower = 0; + int c_digit = 0; + int c_punct = 0; + int c_tot = 0; + int i, len; + + if (!passwd) goto fail; + len = strlen(passwd); + + for (i = 0; i < len; i++) { + + if (c_tot >= 3) break; + + if (isupper(passwd[i])) { + if (!c_upper) { + c_upper = 1; + c_tot += 1; + } + continue; + } + if (islower(passwd[i])) { + if (!c_lower) { + c_lower = 1; + c_tot += 1; + } + continue; + } + if (isdigit(passwd[i])) { + if (!c_digit) { + c_digit = 1; + c_tot += 1; + } + continue; + } + if (ispunct(passwd[i])) { + if (!c_punct) { + c_punct = 1; + c_tot += 1; + } + continue; + } + } + + if ((c_tot) < 3) goto fail; + return 0; + +fail: + fprintf(stderr, "ERR Complexity check failed\n\n"); + return -4; +} + int main(int argc, char **argv) { extern char *optarg; - int c; + int c, ret, complex_check = 0; char f[256]; char *dictionary = NULL; char *password; char *reply; - while ( (c = getopt(argc, argv, "d:")) != EOF){ + while ( (c = getopt(argc, argv, "d:c")) != EOF){ switch(c) { case 'd': dictionary = strdup(optarg); break; + case 'c': + complex_check = 1; + break; default: usage(argv[0]); } @@ -43,6 +104,7 @@ int main(int argc, char **argv) { usage(argv[0]); } + fflush(stdin); password = fgets(f, sizeof(f), stdin); if (password == NULL) { @@ -50,6 +112,13 @@ int main(int argc, char **argv) { exit(-2); } + if (complex_check) { + ret = complexity(password); + if (ret) { + exit(ret); + } + } + reply = FascistCheck(password, dictionary); if (reply != NULL) { fprintf(stderr, "ERR - %s\n\n", reply); -- cgit From d186ff50721011f839a02aaac4866201eda23034 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 26 Dec 2005 17:36:33 +0000 Subject: r12497: add a simplex option better usage message (This used to be commit c007f20c955f224c6a8deeb0b1f82e8432f1b9ab) --- examples/auth/crackcheck/crackcheck.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'examples/auth') diff --git a/examples/auth/crackcheck/crackcheck.c b/examples/auth/crackcheck/crackcheck.c index 0636114a17..ac29b22592 100644 --- a/examples/auth/crackcheck/crackcheck.c +++ b/examples/auth/crackcheck/crackcheck.c @@ -13,9 +13,11 @@ void usage(char *command) { comm = c + 1; } - fprintf(stderr, "Usage: %s -d dictionary\n\n", comm); - fprintf(stderr, " -d dictionary file for cracklib\n\n"); - fprintf(stderr, " The password is expected to be given via stdin.\n\n"); + fprintf(stderr, "Usage: %s [-c] [-s] [-d ]\n\n", comm); + fprintf(stderr, " -c enables NT like complexity checks\n"); + fprintf(stderr, " -d for cracklib\n"); + fprintf(stderr, " -s simple check use NT like checks ONLY\n\n"); + fprintf(stderr, "The password is read via stdin.\n\n"); exit(-1); } @@ -79,14 +81,14 @@ fail: int main(int argc, char **argv) { extern char *optarg; - int c, ret, complex_check = 0; + int c, ret, complex_check = 0, simplex_check = 0; char f[256]; char *dictionary = NULL; char *password; char *reply; - while ( (c = getopt(argc, argv, "d:c")) != EOF){ + while ( (c = getopt(argc, argv, "d:cs")) != EOF){ switch(c) { case 'd': dictionary = strdup(optarg); @@ -94,13 +96,17 @@ int main(int argc, char **argv) { case 'c': complex_check = 1; break; + case 's': + complex_check = 1; + simplex_check = 1; + break; default: usage(argv[0]); } } - if (dictionary == NULL) { - fprintf(stderr, "ERR - Wrong Command Line\n\n"); + if (!simplex_check && dictionary == NULL) { + fprintf(stderr, "ERR - Missing cracklib dictionary\n\n"); usage(argv[0]); } @@ -119,6 +125,10 @@ int main(int argc, char **argv) { } } + if (simplex_check) { + exit(0); + } + reply = FascistCheck(password, dictionary); if (reply != NULL) { fprintf(stderr, "ERR - %s\n\n", reply); @@ -126,6 +136,5 @@ int main(int argc, char **argv) { } exit(0); - } -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- examples/auth/auth_skel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/auth') diff --git a/examples/auth/auth_skel.c b/examples/auth/auth_skel.c index bcc3bdd96a..f20d07b922 100644 --- a/examples/auth/auth_skel.c +++ b/examples/auth/auth_skel.c @@ -6,7 +6,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 58e9534300430fa4f2bcb50fb2d1d2990bdbe636 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:57:11 +0000 Subject: r23785: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit d0e89d246d8e5e64196d6c1d16d39a70579ca42f) --- examples/auth/auth_skel.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'examples/auth') diff --git a/examples/auth/auth_skel.c b/examples/auth/auth_skel.c index f20d07b922..e6cbd73968 100644 --- a/examples/auth/auth_skel.c +++ b/examples/auth/auth_skel.c @@ -15,8 +15,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit