Browse Source

Merge pull request #5 from alessio/master

Merging patches from Debian to upstream
master
Andrea Luzzardi 12 years ago
parent
commit
698131bf7b
4 changed files with 25 additions and 8 deletions
  1. +8
    -5
      Makefile
  2. +2
    -0
      src/conf.h
  3. +13
    -3
      src/pad.c
  4. +2
    -0
      src/volume.c

+ 8
- 5
Makefile View File

@ -1,6 +1,9 @@
# Set to 'yes' to include debugging informations, e.g. DEBUG=yes make -e
# Set to 'yes' to include debugging information, e.g. DEBUG=yes make -e
DEBUG := no
PREFIX ?= /usr
LIBDIR ?= lib
# compiler/linker options
CC := gcc
CFLAGS := $(CFLAGS) -Wall -fPIC `pkg-config --cflags libxml-2.0` \
@ -25,7 +28,7 @@ PAM_USB_SRCS := src/pam.c
PAM_USB_OBJS := $(PAM_USB_SRCS:.c=.o)
PAM_USB := pam_usb.so
PAM_USB_LDFLAGS := -shared
PAM_USB_DEST := $(DESTDIR)/lib/security
PAM_USB_DEST := $(DESTDIR)/$(LIBDIR)/security
# pamusb-check
PAMUSB_CHECK_SRCS := src/pamusb-check.c
@ -35,7 +38,7 @@ PAMUSB_CHECK := pamusb-check
# Tools
PAMUSB_CONF := pamusb-conf
PAMUSB_AGENT := pamusb-agent
TOOLS_DEST := $(DESTDIR)/usr/bin
TOOLS_DEST := $(DESTDIR)$(PREFIX)/bin
TOOLS_SRC := tools
# Conf
@ -44,11 +47,11 @@ CONFS_DEST := $(DESTDIR)/etc
# Doc
DOCS := doc/CONFIGURATION.md
DOCS_DEST := $(DESTDIR)/usr/share/doc/pamusb
DOCS_DEST := $(DESTDIR)$(PREFIX)/share/doc/pamusb
# Man
MANS := doc/pamusb-conf.1.gz doc/pamusb-agent.1.gz doc/pamusb-check.1.gz
MANS_DEST := $(DESTDIR)/usr/share/man/man1
MANS_DEST := $(DESTDIR)$(PREFIX)/share/man/man1
# Binaries
RM := rm


+ 2
- 0
src/conf.h View File

@ -23,7 +23,9 @@
# define CONF_SERVICE_XPATH "//configuration/services/service[@id='%s']/%s"
# define CONF_USER_MAXLEN 32
# include <limits.h>
#ifdef __linux__
# include <linux/limits.h>
#endif
# include <sys/time.h>
# ifndef PATH_MAX
# define PATH_MAX 4096


+ 13
- 3
src/pad.c View File

@ -22,6 +22,7 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <pwd.h>
#include <time.h>
#include "conf.h"
@ -73,7 +74,7 @@ static FILE *pusb_pad_open_system(t_pusb_options *opts,
if (!(user_ent = getpwnam(user)) || !(user_ent->pw_dir))
{
log_error("Unable to retrieve informations for user \"%s\": %s\n",
log_error("Unable to retrieve information for user \"%s\": %s\n",
strerror(errno));
return (0);
}
@ -111,7 +112,7 @@ static int pusb_pad_protect(const char *user, int fd)
log_debug("Protecting pad file...\n");
if (!(user_ent = getpwnam(user)))
{
log_error("Unable to retrieve informations for user \"%s\": %s\n",
log_error("Unable to retrieve information for user \"%s\": %s\n",
strerror(errno));
return (0);
}
@ -181,6 +182,8 @@ static void pusb_pad_update(t_pusb_options *opts,
FILE *f_system = NULL;
char magic[1024];
int i;
unsigned int seed;
int devrandom;
if (!pusb_pad_should_update(opts, user))
return ;
@ -201,7 +204,14 @@ static void pusb_pad_update(t_pusb_options *opts,
pusb_pad_protect(user, fileno(f_system));
log_debug("Generating %d bytes unique pad...\n", sizeof(magic));
srand(getpid() * time(NULL));
devrandom = open("/dev/random", O_RDONLY);
if (devrandom < 0 || read(devrandom, &seed, sizeof seed) != sizeof seed) {
log_debug("/dev/random seeding failed...\n");
seed = getpid() * time(NULL); /* low-entropy fallback */
}
if (devrandom > 0)
close(devrandom);
srand(seed);
for (i = 0; i < sizeof(magic); ++i)
magic[i] = (char)rand();
log_debug("Writing pad to the device...\n");


+ 2
- 0
src/volume.c View File

@ -21,7 +21,9 @@
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#ifndef __GNU__
#include <sys/mount.h>
#endif
#include "mem.h"
#include "conf.h"
#include "log.h"


Loading…
Cancel
Save