diff options
author | stevel@tonic-gate <none@none> | 2005-06-14 00:00:00 -0700 |
---|---|---|
committer | stevel@tonic-gate <none@none> | 2005-06-14 00:00:00 -0700 |
commit | 7c478bd95313f5f23a4c958a745db2134aa03244 (patch) | |
tree | c871e58545497667cbb4b0a4f2daf204743e1fe7 /usr/src/cmd/mkpwdict | |
download | illumos-gate-7c478bd95313f5f23a4c958a745db2134aa03244.tar.gz |
OpenSolaris Launch
Diffstat (limited to 'usr/src/cmd/mkpwdict')
-rw-r--r-- | usr/src/cmd/mkpwdict/Makefile | 66 | ||||
-rw-r--r-- | usr/src/cmd/mkpwdict/inc.flg | 27 | ||||
-rw-r--r-- | usr/src/cmd/mkpwdict/mkpwdict.c | 138 |
3 files changed, 231 insertions, 0 deletions
diff --git a/usr/src/cmd/mkpwdict/Makefile b/usr/src/cmd/mkpwdict/Makefile new file mode 100644 index 0000000000..cb11b13dab --- /dev/null +++ b/usr/src/cmd/mkpwdict/Makefile @@ -0,0 +1,66 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +PROG= mkpwdict + + +include ../Makefile.cmd + +CFLAGS += -I$(SRC)/lib/pam_modules/authtok_check +LINTFLAGS += -erroff=E_NAME_DEF_NOT_USED2 -m +LINTFLAGS += -I$(SRC)/lib/pam_modules/authtok_check + +LDLIBS += -lcmd + +CRACK_SRCDIR= $(SRC)/lib/pam_modules/authtok_check/ +CRACK_OBJS= packer.o packlib.o dict.o stringlib.o +CRACK_SRCS= $(CRACK_OBJS:%.o=$(CRACK_SRCDIR)/%.c) + +OBJS= $(CRACK_OBJS) mkpwdict.o +SRCS= $(CRACK_SRCS) mkpwdict.c + +.KEEP_STATE: + +all: $(PROG) + +install: all $(ROOTPROG) + +%.o: $(CRACK_SRCDIR)/%.c + $(COMPILE.c) -o $@ $< + $(POST_PROCESS_O) + +mkpwdict: $(OBJS) + $(LINK.c) -o $@ $(OBJS) $(LDLIBS) + $(POST_PROCESS) + +clean: + $(RM) $(PROG) $(OBJS) + +lint: lint_SRCS + +include ../Makefile.targ diff --git a/usr/src/cmd/mkpwdict/inc.flg b/usr/src/cmd/mkpwdict/inc.flg new file mode 100644 index 0000000000..64ae5494fd --- /dev/null +++ b/usr/src/cmd/mkpwdict/inc.flg @@ -0,0 +1,27 @@ +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +#ident "%Z%%M% %I% %E% SMI" + +find_files "s.*" usr/src/lib/pam_modules/authtok_check diff --git a/usr/src/cmd/mkpwdict/mkpwdict.c b/usr/src/cmd/mkpwdict/mkpwdict.c new file mode 100644 index 0000000000..18ce36b135 --- /dev/null +++ b/usr/src/cmd/mkpwdict/mkpwdict.c @@ -0,0 +1,138 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <string.h> +#include <stdlib.h> +#include <stdio.h> +#include <errno.h> +#include <deflt.h> +#include <locale.h> +#include <libintl.h> +#include "packer.h" + +char options[] = "s:d:"; + +char *pname; + +void +fatal(char *msg) +{ + (void) fprintf(stderr, "%s: Fatal error: %s. Database not remade.\n", + pname, msg); + exit(-1); +} + +void +usage(void) +{ + (void) fprintf(stderr, + "usage: %s [-s dict1,...,dictn ] [-d dest-path ]\n", pname); + exit(-1); +} + +int +main(int argc, char *argv[]) +{ + char *default_dbdst = NULL; + char *default_dbsrc = NULL; + char *p; + + char *dbdst = NULL; + char *dbsrc = NULL; + size_t dbsrc_len = 0; + int c; + int result; + + (void) setlocale(LC_ALL, ""); + + if ((pname = strrchr(argv[0], '/')) == NULL) + pname = argv[0]; + else + pname++; + + if (defopen(PWADMIN) == 0) { + if ((p = defread("DICTIONLIST=")) != NULL) + default_dbsrc = strdup(p); + if ((p = defread("DICTIONDBDIR=")) != NULL) + default_dbdst = strdup(p); + (void) defopen(NULL); + } + + if (default_dbdst == NULL) + default_dbdst = CRACK_DIR; + + while ((c = getopt(argc, argv, options)) != EOF) { + switch (c) { + case 's': + if (dbsrc != NULL) { + dbsrc_len += strlen(optarg) + 2; /* ',' + \0 */ + if ((dbsrc = realloc(dbsrc, dbsrc_len)) == NULL) + fatal(strerror(errno)); + (void) strlcat(dbsrc, ",", dbsrc_len); + (void) strlcat(dbsrc, optarg, dbsrc_len); + } else { + if ((dbsrc = strdup(optarg)) == NULL) + fatal(strerror(errno)); + dbsrc_len = strlen(optarg) + 1; + } + break; + case 'd': + dbdst = optarg; + break; + default: + usage(); + break; + } + } + if (optind != argc) + usage(); + + if (dbdst == NULL) { + (void) fprintf(stderr, + gettext("%s: using default database location: %s.\n"), + pname, default_dbdst); + dbdst = default_dbdst; + } + + if (dbsrc == NULL) + if ((dbsrc = default_dbsrc) == NULL) + fatal(gettext("No source databases defined")); + else + (void) fprintf(stderr, + gettext("%s: using default dictionary list: %s.\n"), + pname, default_dbsrc); + + if ((result = lock_db(dbdst)) == 0) { + PWRemove(dbdst); + result = build_dict_database(dbsrc, dbdst); + unlock_db(); + } + if (result != 0) + fatal(strerror(errno)); + return (0); +} |