+Tue Jan 11 02:02:00 CET 2000 Wichert Akkerman <wakkerma@debian.org>
+
+ * dselect/baselist.cc: don't specify SA_INTERRUPT, since it's
+ not portable and the default behaviour
+ * main/enquiry.c: include sys/termios.h (needed on Solaris)
+ * lib/lock.c: use EACCESS instead of EWOULDBLOCK
+ * dselect/main.cc: fix help for -D
+ * dselect/main.cc: try to lock admindir instead of using readwrite
+ * dselect/method.cc: switch to using fcntl for lock since that is more
+ portable, and revamp lockingcode to reduce code duplication
+
Sun Jan 9 16:11:39 CET 2000 Wichert Akkerman <wakkerma@debian.org>
* Merge patches from Josip Rodin:
memset(&nsigact,0,sizeof(nsigact));
nsigact.sa_handler= sigwinchhandler;
sigemptyset(&nsigact.sa_mask);
- nsigact.sa_flags= SA_INTERRUPT;
+//nsigact.sa_flags= SA_INTERRUPT;
if (sigaction(SIGWINCH,&nsigact,0)) ohshite(_("failed to set new SIGWINCH sigact"));
}
#include "bindings.h"
#include "pkglist.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
const char thisname[]= DSELECT;
const char printforhelp[]= N_("Type dselect --help for help.");
_("Usage: dselect [options]\n"
" dselect [options] action ...\n"
"Options: --admindir <directory> (default is /var/lib/dpkg)\n"
- " --help --version --licence --expert --debug <file> | -D<file> | -D\n"
+ " --help --version --licence --expert --debug <file> | -D<file>\n"
"Actions: access update select install config remove quit menu\n"),
stdout)) werr("stdout");
}
int refreshmenu(void) {
char buf[2048];
+ static int l,lockfd;
+ static char *lockfile;
+
curseson(); cbreak(); noecho(); nonl(); keypad(stdscr,TRUE);
int y,x;
sprintf(buf,gettext(copyrightstring),DPKG_VERSION_ARCH);
addstr(buf);
- if (!readwrite) {
- addstr(_("\n\n"
- "Read-only access: only preview of selections is available!"));
- }
+ l = strlen(admindir);
+ lockfile = new char[l+sizeof(LOCKFILE)+2];
+ strcpy(lockfile,admindir);
+ strcpy(lockfile+l, "/" LOCKFILE);
+ lockfd = open(lockfile, O_RDWR|O_CREAT|O_TRUNC, 0660);
+ if (errno == EACCES || errno == EPERM)
+ addstr(_("\n\n"
+ "Read-only access: only preview of selections is available!"));
return i;
}
static char *methodlockfile= 0;
static int methlockfd= -1;
+void sthfailed(const char * reasoning) {
+ char buf[2048];
+
+ curseson();
+ clear();
+ sprintf(buf,_("\n\n%s: %s\n"),DSELECT,reasoning);
+ addstr(buf);
+ attrset(A_BOLD);
+ addstr(_("\nPress <enter> to continue."));
+ attrset(A_NORMAL);
+ refresh(); getch();
+}
+
static void cu_unlockmethod(int, void**) {
+ struct flock fl;
+
assert(methodlockfile);
assert(methlockfd);
- if (flock(methlockfd,LOCK_UN))
- ohshite(_("unable to unlock access method area"));
+ fl.l_type=F_UNLCK; fl.l_whence= SEEK_SET; fl.l_start=fl.l_len=0;
+ if (fcntl(methlockfd,F_SETLK,&fl) == -1)
+ sthfailed("unable to unlock access method area");
}
static enum urqresult ensureoptions(void) {
for (ccpp= methoddirectories; *ccpp; ccpp++)
readmethods(*ccpp, &newoptions, &nread);
if (!newoptions) {
- curseson();
- addstr(_("No access methods are available.\n\n"
- "Press <enter> to continue."));
- refresh(); getch();
+ sthfailed("no access methods are available");
return urqr_fail;
}
options= newoptions;
return urqr_normal;
}
-static void lockfailed(const char * reasoning) {
- char buf[2048];
-
- curseson();
- clear();
- sprintf(buf,_("\n\n%s: %s\n"),DSELECT,reasoning);
- addstr(buf);
- attrset(A_BOLD);
- addstr(_("\nPress <enter> to continue."));
- attrset(A_NORMAL);
- refresh(); getch();
-}
-
static enum urqresult lockmethod(void) {
+ struct flock fl;
+
if (!methodlockfile) {
int l;
l= strlen(admindir);
methlockfd= open(methodlockfile, O_RDWR|O_CREAT|O_TRUNC, 0660);
if (methlockfd == -1) {
if ((errno == EPERM) || (errno == EACCES)) {
- lockfailed("requested operation requires superuser privilege");
+ sthfailed("requested operation requires superuser privilege");
return urqr_fail;
}
- lockfailed("unable to open/create access method lockfile");
+ sthfailed("unable to open/create access method lockfile");
return urqr_fail;
}
}
- if (flock(methlockfd,LOCK_EX|LOCK_NB)) {
+ fl.l_type=F_WRLCK; fl.l_whence=SEEK_SET; fl.l_start=fl.l_len=0;
+ if (fcntl(methlockfd,F_SETLK,&fl) == -1) {
if (errno == EWOULDBLOCK || errno == EAGAIN) {
- lockfailed("the access method area is already locked");
+ sthfailed("the access method area is already locked");
return urqr_fail;
}
- lockfailed("unable to lock access method area");
+ sthfailed("unable to lock access method area");
return urqr_fail;
}
push_cleanup(cu_unlockmethod,~0, 0,0, 0);
};
ur= falliblesubprocess(coption->meth->path,name,fallibleargs);
} else {
- curseson();
- addstr(_("No access method is selected/configured.\n\n"
- "Press <enter> to continue."));
- refresh(); getch();
+ sthfailed("no access method is selected/configured");
ur= urqr_fail;
}
pop_cleanup(ehflag_normaltidy);
fl.l_start= 0;
fl.l_len= 0;
if (fcntl(dblockfd,F_SETLK,&fl) == -1) {
- if (errno == EWOULDBLOCK || errno == EAGAIN)
- ohshit(_("status database area is locked - another dpkg/dselect is running"));
+ if (errno == EACCES || errno == EAGAIN)
+ ohshit(_("status database area is locked by another process"));
ohshite(_("unable to lock dpkg status database"));
}
push_cleanup(cu_unlockdb,~0, 0,0, 0);
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
+#include <sys/termios.h>
#include <fcntl.h>
#include <config.h>
include ../Makefile.conf
-CFLAGS += $(top_srcdir)/optlib
+CFLAGS += -I$(top_srcdir)/optlib
SSD_SOURCES = start-stop-daemon.c
SSD_OBJECTS = $(patsubst %.c, %.o, $(SSD_SOURCES))