Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ liblockfile (1.13)

* remove '-t' as option when running a command- do touchlock
automatically if -p was not given.
* drop effective gid asap, retain as saved gid. only restore egid if nessecary.
* drop effective gid asap, retain as saved gid. only restore egid if necessary.
* if stat() fails, drop saved gid as well, and retry (sshfs is strict)
* don't allow executing a command with the -m option, not nessecary.
* don't allow executing a command with the -m option, not necessary.
should really add a minimal setgid util for maillock(), remove setgid
from dotlockfile, and let it use the library maillock().

Expand Down Expand Up @@ -294,7 +294,7 @@ liblockfile (0.1-2) unstable; urgency=low
* Compiled with libc6 and with -lc
* Compile with -D_REENTRANT and -D_GNU_SOURCE
* Apart from returning the L_XXX values, also set errno to something
resonable.
reasonable.
* Reckognize common NFS lockfiles from mailx

-- Miquel van Smoorenburg <miquels@cistron.nl> Wed, 24 Sep 1997 12:52:44 +0200
Expand Down
1 change: 0 additions & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,3 @@ distclean: clean
rm -f Makefile autoconf.h maillock.h \
config.cache config.log config.status; \
rm -rf autom4te.cache

3 changes: 0 additions & 3 deletions README
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

README for liblockfile


Expand Down Expand Up @@ -37,5 +36,3 @@ lockfile_create,
lockfile_remove,
lockfile_touch,
lockfile_check - lockfile_create.3


1 change: 0 additions & 1 deletion acconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ config.h - created by autoconf; contains defines generated by autoconf

/* Is the mailspool group writable */
#undef MAILGROUP

9 changes: 4 additions & 5 deletions dotlockfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ int set_signal(int sig, void (*handler)(int))
}

/*
* Sleep for an amount of time while regulary checking if
* Sleep for an amount of time while regularly checking if
* our parent is still alive.
*/
int check_sleep(int sleeptime, int flags)
Expand All @@ -104,7 +104,7 @@ int check_sleep(int sleeptime, int flags)
}

/*
* Split a filename up in file and directory.
* Split a filename up in file and directory.
*/
int fn_split(char *fn, char **fn_p, char **dir_p)
{
Expand Down Expand Up @@ -164,7 +164,7 @@ void perror_exit(const char *why) {
}

/*
* Print usage mesage and exit.
* Print usage message and exit.
*/
void usage(void)
{
Expand Down Expand Up @@ -322,7 +322,7 @@ int main(int argc, char **argv)
if (gid != egid) {
/*
* See if the requested lock is for a mailbox.
* First, remember currect working directory.
* First, remember current working directory.
*/
#ifdef O_PATH
cwd_fd = open(".", O_PATH|O_CLOEXEC);
Expand Down Expand Up @@ -456,4 +456,3 @@ int main(int argc, char **argv)
}
return 0;
}

1 change: 0 additions & 1 deletion lockfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,4 +611,3 @@ void touchlock(void)
lockfile_touch(mlockfile);
}
#endif

6 changes: 3 additions & 3 deletions lockfile_create.3
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH LOCKFILE_CREATE 3 "27 Januari 2021" "Linux Manpage" "Linux Programmer's Manual"
.TH LOCKFILE_CREATE 3 "27 January 2021" "Linux Manpage" "Linux Programmer's Manual"
.SH NAME
lockfile_create, lockfile_remove, lockfile_touch, lockfile_check \- manage lockfiles
.SH SYNOPSIS
Expand Down Expand Up @@ -126,7 +126,7 @@ However in a lot of cases, such as Unix mailboxes, all concerned programs
accessing the mailboxes agree on the fact that the presence of
<filename>.lock means that <filename> is locked.
.PP
If you are using
If you are using
.B lockfile_create
to create a lock on a file that resides on a remote server, and you
already have that file open, you need to flush the NFS attribute cache
Expand All @@ -138,7 +138,7 @@ o
open /var/mail/USERNAME
.TP 3
o
attributes, such as size, inode, etc are now cached in the kernel!
attributes, such as size, inode, etc are now cached in the kernel!
.TP 3
o
meanwhile, another remote system appends data to /var/mail/USERNAME
Expand Down
2 changes: 1 addition & 1 deletion maillock.3
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ These functions call
.BR lockfile_create "(3)"
to do the work. That function might spawn a set group-id executable
to do the actual locking if the current process doesn't have enough
priviliges.
privileges.
.PP
There are some issues with flushing the kernels attribute cache if
you are using NFS - see the
Expand Down
1 change: 0 additions & 1 deletion nfslock.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,3 @@ int creat(const char *file, mode_t mode)
{
return open(file, O_CREAT|O_WRONLY|O_TRUNC, mode);
}

19 changes: 8 additions & 11 deletions run-tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/sh
#!/bin/sh
#
# Some simple tests to check if locking/unlocking works correctly.
#
Expand All @@ -25,13 +25,11 @@ PID=$!
sleep 1

# locking again should fail
if dotlockfile -l -r 0 testlock.lock
then
if kill -0 $PID 2>/dev/null
then
echo "double lock while running command"
exit 1
fi
if dotlockfile -l -r 0 testlock.lock; then
if kill -0 "$PID" 2>/dev/null; then
echo "double lock while running command"
exit 1
fi
fi

# lock should be gone when command completes
Expand All @@ -50,11 +48,10 @@ dotlockfile -u testlock.lock
wait

time_end=$(date '+%s')
time_elapsed=`expr $time_end - $time_start`
time_elapsed=$((time_end - time_start))

# Time should equal 8 seconds
[ "$time_elapsed" = '8' ] || { echo "lockfile should take 8 seconds to be replaced. [$time_elapsed]"; exit 1; }
[ "$time_elapsed" = 8 ] || { echo "lockfile should take 8 seconds to be replaced. [$time_elapsed]"; exit 1; }
[ ! -f testlock.lock ] || { echo "lockfile still exists after running cmd"; exit 1; }

echo "tests OK"