Skip to content

Commit

Permalink
Version 1.30 released on 2005-05-27 09:09
Browse files Browse the repository at this point in the history
  • Loading branch information
dagwieers committed Jun 5, 2012
1 parent deb00b2 commit 2ca3c3b
Show file tree
Hide file tree
Showing 13 changed files with 308 additions and 130 deletions.
4 changes: 2 additions & 2 deletions .todo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Automagically generated by the ToDo program on 14/04/05, 23:43 -->
<!-- Automagically generated by the ToDo program on 20/05/05, 12:57 -->
<todo version="0.1.18">
<note priority="medium" time="1031933086" done="1049945562">
Add note about regular expression searching (^athomas$)
Expand Down Expand Up @@ -27,7 +27,7 @@
<note priority="medium" time="1108077380" done="1112841219">
Make a "nolog" option to prevent logging - for automated commands.
</note>
<note priority="medium" time="1113486219">
<note priority="medium" time="1113486219" done="1116557866">
Fix bug where $VARS aren't being expanded correctly inside quotes. This is occurring in main.c.
</note>
</todo>
2 changes: 1 addition & 1 deletion .todo.1
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
Make a "nolog" option to prevent logging - for automated commands.
</note>
<note priority="medium" time="1113486219">
Fix bug where $VARS aren't being expanded correctly inside quotes.
Fix bug where $VARS aren't being expanded correctly inside quotes. This is occurring in main.c.
</note>
</todo>
17 changes: 10 additions & 7 deletions .todo.2
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<!-- Automagically generated by the ToDo program on 07/04/05, 12:33 -->
<!-- Automagically generated by the ToDo program on 14/04/05, 23:43 -->
<todo version="0.1.18">
<note priority="veryhigh" time="1031936628" done="1049945547">
Fix limitation on parentheses recursion - use system regex library instead of bundled one?
<comment>
Increased recursion limit and increased maximum buffer length to 4K
</comment>
</note>
<note priority="medium" time="1031933086" done="1049945562">
Add note about regular expression searching (^athomas$)
<comment>
Forced regular expressions to have ^ prepended and $ appended. Safer.
</comment>
</note>
<note priority="veryhigh" time="1031936628" done="1049945547">
Fix limitation on parentheses recursion - use system regex library instead of bundled one?
<comment>
Increased recursion limit and increased maximum buffer length to 4K
</comment>
</note>
<note priority="medium" time="1050479786" done="1050562957">
Add minimal 'ifdef' facility, ie. have the same command do different things on different hosts and/or for different users/groups, etc.
<comment>
Expand All @@ -27,4 +27,7 @@
<note priority="medium" time="1108077380" done="1112841219">
Make a "nolog" option to prevent logging - for automated commands.
</note>
<note priority="medium" time="1113486219">
Fix bug where $VARS aren't being expanded correctly inside quotes.
</note>
</todo>
19 changes: 19 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,22 @@ Cleaned up the code a bit, adding some basic dynamic array functions instead of
replicating the code across multiple areas.

Closes #4

27/05/05- op 1.30
==================
Fixed use of DEFAULT section, closes #5. Quite a pain in the arse actually.

Environment variables can now be propagated into child environments even when
"environment" is specified. This will override any existing variables.

Now using vsnprintf rather than snprintf. Correspondingly, changed preprocessor
define which may mean build scripts need to be changed.

Added an INSTALL file documenting the usual installation instructions.

Default to using Flex, as Lex has internal constraints.

Added default op.pam which is now installed if /etc/pam.d exists.

Added patches by Pierre fixing strnprintf issues and a wildcard constraint bug.
Thanks Pierre.
52 changes: 52 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Building
========
To build op, the best option is to override the default Makefile settings
with ones appropriate for your system (the alternative is to edit the Makefile,
uncommenting the appropriate sections).

op requires Flex (it will not work with standard Lex due to internal
limitations on data structures in Lex).

Compiler flags are put into OPTS (this is a legacy setting), libraries in LIBS
and link flags in LDFLAGS.

Build for typical PAM enabled Linux system:
make OPTS='-DXAUTH=\"/usr/X11R6/bin/xauth\" -DUSE_PAM' \
LIBS='-lcrypt -lpam -lfl' LDFLAGS='-Wl,-z,now'

Build for typical Solaris system with PAM:
make LEX=flex OPTS='-DXAUTH=\"/usr/X/bin/xauth\" -DUSE_PAM' \
LIBS='-lcrypt -lpam -lfl'

The available features are:

Debugging:
Compiler flags: -g -DDEBUG
Link flags: -g

PAM:
Compiler flags: -DUSE_PAM
Libraries: -lpam

Shadow support:
Compiler flags: -DUSE_SHADOW
Libraries: -lshadow

Use Flex:
Libraries: -lfl

XAuth support:
Compiler flags: -DXAUTH=\"<full-path-to-xauth>\"

If you have vsnprintf on your system:
Compiler flags: -DHAVE_VSNPRINTF

Note: For SecureID support, read the Makefile and uncomment the appropriate
section.

Installing
==========
"make install" will do a normal install. Optionally, DESTDIR can be used to
install into a package root:

make DESTDIR=/tmp/pkg install
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#
CC=gcc
INC= -I. -Wall
LIBS= -ll -L/lib -lcrypt
LEX = flex
LIBS= -lfl -L/lib -lcrypt
DESTDIR=
PREFIX=/usr
CONFDIR= $(DESTDIR)/etc/op.d
Expand All @@ -26,17 +27,17 @@ OPTS += -g -DDEBUG
LDFLAGS += -g

# Enable PAM support
#OPTS += -DUSE_PAM
#LDFLAGS += -lpam
OPTS += -DUSE_PAM
LIBS += -lpam

# Enable shadow support (generally not used in conjunction with PAM)
OPTS += -DUSE_SHADOW
#OPTS += -DUSE_SHADOW

# Enable XAUTH support
OPTS += -DXAUTH=\"/usr/X11R6/bin/xauth\"

# We have snprintf(3)
OPTS += -DHAVE_SNPRINTF
# We have vsnprintf(3) (more secure)
OPTS += -DHAVE_VSNPRINTF

############################ LEGACY CONFIG ####################################
#
Expand Down Expand Up @@ -97,9 +98,10 @@ install: op
mkdir -p $(MANDIR)
$(INSTALL-MAN)
mkdir -p $(CONFDIR)
test -d /etc/pam.d && install -m755 -d ${DESTDIR}/etc/pam.d && install -m644 op.pam ${DESTDIR}/etc/pam.d/op

pkg: op
(umask 022; mkdir -p pkg/usr/bin pkg/usr/share/man/man1; mv op pkg/usr/bin; cp op.1 pkg/usr/share/man/man1; strip pkg/usr/bin/op; chown -R root:root pkg; chmod 4755 pkg/usr/bin/op; chmod 644 pkg/usr/share/man/man1/op.1)
(umask 022; mkdir pkg; make DESTDIR=${PWD}/pkg install)

dist: clean
(V=`grep VERSION defs.h | cut -d\" -f2`; rm -rf pkg; rm -f op-$$V.tar.gz; cd .. && mv op op-$$V && tar --exclude 'op.list' --exclude '.*.swp' --exclude '.svn' -czv -f op-$$V.tar.gz op-$$V && mv op-$$V op && mv op-$$V.tar.gz op)
3 changes: 2 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,6 @@ long last.
Ditto for my contributions which are Copyright (C) 1995, 1997 by
Howard Owen. ([email protected])

And again for contributions by me, Alec Thomas, Copyright (C) 2002-2004.
And again for contributions by me, Alec Thomas ([email protected]),
Copyright (C) 2002-2005.

6 changes: 4 additions & 2 deletions defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ void *array_push(array_t *array, void *object);
void *array_pop(array_t *array);
int array_extend(array_t *array, int capacity);

extern cmd_t *First, *Build();
extern cmd_t *First, *Build(), *BuildSingle();
extern var_t *Variables;
extern unsigned minimum_logging_level;

void fatal(int logit, const char *format, ...);
int logger(unsigned flags, const char *format, ...);
void strnprintf(char *out, int len, const char *format, va_list ap);
char *strtolower(char *in);

int ReadFile(char *file);
int ReadDir(char *dir);
Expand All @@ -53,7 +55,7 @@ int atov(char *str, int type);
#define MAXSTRLEN 2048
#define OP_ACCESS "/etc/op.conf"
#define OP_ACCESS_DIR "/etc/op.d"
#define VERSION "1.29"
#define VERSION "1.30"

#define VAR_EXPAND_LEN 8192
#define VAR_NAME_LEN 64
Expand Down
46 changes: 35 additions & 11 deletions lex.l
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,13 @@ char *str;
return s;
}

static cmd_t *newcmd(name)
char *name;
static cmd_t *alloccmd(char *name)
{
cmd_t *cmd = (cmd_t *)malloc(sizeof(cmd_t));

if (cmd == NULL)
fatal(1, "Unable to alloc space for new command");

cmd->next = First;
First = cmd;

cmd->name = savestr(name);
cmd->nargs = 0; cmd->margs = 16;
cmd->nopts = 0; cmd->mopts = 16;
Expand All @@ -266,6 +262,17 @@ char *name;
return cmd;
}

static cmd_t *newcmd(char *name)
{
cmd_t *cmd = alloccmd(name);

cmd->next = First;
First = cmd;

return cmd;

}

int ReadFile(file)
char *file;
{
Expand Down Expand Up @@ -379,11 +386,11 @@ cmd_t *cmd;
qsort(cmd->opts, cmd->nopts, sizeof(char *), cmpopts);
}

cmd_t *Build(def, cmd)
cmd_t *def, *cmd;
/* Build a new command but don't merge it into the global list */
cmd_t *BuildSingle(cmd_t *def, cmd_t *cmd)
{
cmd_t *new = newcmd("");
char defname[MAXSTRLEN], optname[MAXSTRLEN], *cp;
cmd_t *new = alloccmd(cmd->name ? cmd->name : "");
char defname[MAXSTRLEN], optname[MAXSTRLEN], *cp;
int i, j;
#ifndef _AIX
extern char *strchr();
Expand All @@ -397,6 +404,8 @@ cmd_t *def, *cmd;
addarg(0, new, cmd->args[i]);

for (i = 0; i < def->nopts; i++) {
int skipped = 0;

if ((cp = strchr(def->opts[i], '=')) == NULL)
strcpy(defname, def->opts[i]);
else {
Expand All @@ -412,9 +421,12 @@ cmd_t *def, *cmd;
strncpy(optname, cmd->opts[j], l);
optname[l] = '\0';
}
if (strcmp(defname, optname) == 0)
def->opts[i][0] = '\0';
if (strcmp(defname, optname) == 0) {
skipped = 1;
break;
}
}
if (skipped) continue;
if (def->opts[i][0] != '\0')
addarg(1, new, def->opts[i]);
}
Expand All @@ -425,3 +437,15 @@ cmd_t *def, *cmd;

return new;
}


/* Build a new command *and* merge it with the global command list */
cmd_t *Build(cmd_t *def, cmd_t *cmd)
{
cmd_t *new = BuildSingle(def, cmd);

new->next = First;
First = new;

return new;
}
Loading

0 comments on commit 2ca3c3b

Please sign in to comment.