added devmon 1.1.0 automounting script to udevil distribution

This commit is contained in:
IgnorantGuru 2012-05-25 11:38:42 -06:00
parent 952cddc64f
commit 710bcbca5d
7 changed files with 1277 additions and 28 deletions

View File

@ -1,5 +1,6 @@
0.2.1
log error msgs when parsing network url
added devmon 1.1.0 automounting script to udevil distribution
0.2.0 2012-05-22:
initial test release

5
README
View File

@ -34,7 +34,8 @@ DESCRIPTION
Mounts and unmounts optical and removable devices without a password (set
suid), shows device info, monitors device changes. Emulates mount's and
udisks's command line usage and udisks v1's output.
udisks's command line usage and udisks v1's output. Includes the devmon
automounting daemon.
Run 'udevil --help' for usage. See /etc/udevil/udevil.conf for config.
http://ignorantguru.github.com/udevil/udevil--help.html
@ -99,6 +100,8 @@ BUILD
libglib2.0-0 libglib2.0-dev libudev0 (>=143) libudev-dev
autotools-dev build-essential fakeroot intltool pkg-config
Also recommended if using devmon: eject zenity
configure will report anything missing when you run it as shown below.
2) Use these commands to download the udevil tarball and build:

8
debian/control vendored
View File

@ -12,8 +12,10 @@ Package: udevil
Architecture: any
Depends: libc6, libglib2.0-0, libudev0 (>=143)
Recommends:
Suggests:
Conflicts:
Suggests: eject
Conflicts: devmon
Provides: devmon
Description: Mounts and unmounts optical and removable devices without a
password (set suid), shows device info, monitors device changes.
password (set suid), shows device info, monitors device changes. Includes the
devmon automounting script.

View File

@ -2,6 +2,8 @@ noinst_PROGRAMS = udevil
udevil_SOURCES = udevil.c device-info.c realpath.c
bin_SCRIPTS = devmon
INSTALL_DIR = $(DESTDIR)/$(prefix)/bin
INSTALL_SRC = $(top_builddir)/src

View File

@ -15,6 +15,7 @@
@SET_MAKE@
VPATH = @srcdir@
am__make_dryrun = \
{ \
@ -71,6 +72,35 @@ udevil_DEPENDENCIES = $(am__DEPENDENCIES_1)
udevil_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(udevil_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(bindir)"
SCRIPTS = $(bin_SCRIPTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@ -247,6 +277,7 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
udevil_SOURCES = udevil.c device-info.c realpath.c
bin_SCRIPTS = devmon
INSTALL_DIR = $(DESTDIR)/$(prefix)/bin
INSTALL_SRC = $(top_builddir)/src
udevil_CFLAGS = \
@ -305,6 +336,41 @@ clean-noinstPROGRAMS:
udevil$(EXEEXT): $(udevil_OBJECTS) $(udevil_DEPENDENCIES) $(EXTRA_udevil_DEPENDENCIES)
@rm -f udevil$(EXEEXT)
$(udevil_LINK) $(udevil_OBJECTS) $(udevil_LDADD) $(LIBS)
install-binSCRIPTS: $(bin_SCRIPTS)
@$(NORMAL_INSTALL)
@list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
$(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
done | \
sed -e 'p;s,.*/,,;n' \
-e 'h;s|.*|.|' \
-e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
if ($$2 == $$4) { files[d] = files[d] " " $$1; \
if (++n[d] == $(am__install_max)) { \
print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
else { print "f", d "/" $$4, $$1 } } \
END { for (d in files) print "f", d, files[d] }' | \
while read type dir files; do \
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
test -z "$$files" || { \
echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \
$(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
} \
; done
uninstall-binSCRIPTS:
@$(NORMAL_UNINSTALL)
@list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 's,.*/,,;$(transform)'`; \
dir='$(DESTDIR)$(bindir)'; $(am__uninstall_files_from_dir)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@ -469,8 +535,11 @@ distdir: $(DISTFILES)
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS)
all-am: Makefile $(PROGRAMS) $(SCRIPTS)
installdirs:
for dir in "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
@ -531,7 +600,7 @@ install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-exec-am: install-binSCRIPTS
install-html: install-html-am
@ -571,7 +640,7 @@ ps: ps-am
ps-am:
uninstall-am:
uninstall-am: uninstall-binSCRIPTS
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) uninstall-hook
.MAKE: install-am install-data-am install-strip uninstall-am
@ -580,15 +649,16 @@ uninstall-am:
clean-libtool clean-noinstPROGRAMS ctags distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am \
install-data-hook install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
install install-am install-binSCRIPTS install-data \
install-data-am install-data-hook install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-hook
tags uninstall uninstall-am uninstall-binSCRIPTS \
uninstall-hook
install-data-hook:

1163
src/devmon Executable file

File diff suppressed because it is too large Load Diff

View File

@ -128,7 +128,7 @@ void parse_mounts( gboolean report )
gchar **lines;
GError *error;
guint n;
//printf("\n@@@@@@@@@@@@@ parse_mounts %s\n\n", report ? "TRUE" : "FALSE" );
//fprintf( stderr, "\n@@@@@@@@@@@@@ parse_mounts %s\n\n", report ? "TRUE" : "FALSE" );
contents = NULL;
lines = NULL;
@ -219,7 +219,7 @@ void parse_mounts( gboolean report )
}
g_free( contents );
g_strfreev( lines );
//printf("\nLINES DONE\n\n");
//fprintf( stderr, "\nLINES DONE\n\n");
// translate each mount points list to string
gchar *points, *old_points;
GList* m;
@ -240,7 +240,7 @@ void parse_mounts( gboolean report )
g_list_free( devmount->mounts );
devmount->mounts = NULL;
devmount->mount_points = points;
//printf( "translate %d:%d %s\n", devmount->major, devmount->minor, points );
//fprintf( stderr, "translate %d:%d %s\n", devmount->major, devmount->minor, points );
}
// compare old and new lists
@ -252,16 +252,16 @@ void parse_mounts( gboolean report )
for ( l = newmounts; l; l = l->next )
{
devmount = (devmount_t*)l->data;
//printf("finding %d:%d\n", devmount->major, devmount->minor );
//fprintf( stderr, "finding %d:%d\n", devmount->major, devmount->minor );
found = g_list_find_custom( devmounts, (gconstpointer)devmount,
(GCompareFunc)cmp_devmounts );
if ( found )
if ( found && found->data )
{
//printf(" found\n");
//fprintf( stderr, " found\n");
if ( !g_strcmp0( ((devmount_t*)found->data)->mount_points,
devmount->mount_points ) )
{
//printf(" freed\n");
//fprintf( stderr, " freed\n");
// no change to mount points, so remove from old list
devmount = (devmount_t*)found->data;
g_free( devmount->mount_points );
@ -272,7 +272,7 @@ void parse_mounts( gboolean report )
else
{
// new mount
//printf(" new mount %d:%d\n", devmount->major, devmount->minor );
//fprintf( stderr, " new mount %d:%d\n", devmount->major, devmount->minor );
dev = makedev( devmount->major, devmount->minor );
udevice = udev_device_new_from_devnum( udev, 'b', dev );
if ( udevice )
@ -280,12 +280,12 @@ void parse_mounts( gboolean report )
}
}
}
//printf( "\nREMAINING\n\n");
//fprintf( stderr, "\nREMAINING\n\n");
// any remaining devices in old list have changed mount status
for ( l = devmounts; l; l = l->next )
{
devmount = (devmount_t*)l->data;
//printf("remain %d:%d\n", devmount->major, devmount->minor );
//fprintf( stderr, "remain %d:%d\n", devmount->major, devmount->minor );
if ( report )
{
dev = makedev( devmount->major, devmount->minor );
@ -313,6 +313,7 @@ void parse_mounts( gboolean report )
{
char* bdev = g_path_get_basename( devnode );
printf( "changed: /org/freedesktop/UDisks/devices/%s\n", bdev );
fflush( stdout );
g_free( bdev );
g_free( devnode );
}
@ -333,8 +334,11 @@ static void free_devmounts()
for ( l = devmounts; l; l = l->next )
{
devmount = (devmount_t*)l->data;
g_free( devmount->mount_points );
g_slice_free( devmount_t, devmount );
if ( devmount )
{
g_free( devmount->mount_points );
g_slice_free( devmount_t, devmount );
}
}
g_list_free( devmounts );
devmounts = NULL;
@ -432,6 +436,8 @@ if ( !( cond & G_IO_NVAL ) )
else if ( !strcmp( action, "move" ) )
printf( "moved: /org/freedesktop/UDisks/devices/%s\n", bdev );
g_free( bdev );
fflush( stdout );
fflush( stderr );
}
g_free( devnode );
udev_device_unref( udevice );
@ -3157,7 +3163,7 @@ _get_type:
if ( mount_knows( type == MOUNT_NET ? netmount->url : data->device_file ) )
{
// mount knows (in fstab) so mount as normal user with only specified opts
wlog( "udevil: '%s' is known to mount - running mount as normal user\n",
wlog( "udevil: %s is known to mount - running mount as normal user\n",
data->device_file, 1 );
if ( data->fstype )
wlog( "udevil: warning: fstype ignored for device in fstab (or specify mount point)\n",
@ -3605,6 +3611,8 @@ static int command_info( CommandData* data )
device_free( device );
udev_device_unref( udevice );
udev_unref( udev );
fflush( stdout );
fflush( stderr );
return ret;
}
@ -3805,7 +3813,7 @@ static void show_help()
printf( " udevil help|--help|-h\n" );
printf( "\n" );
printf( "http://ignorantguru.github.com/udevil/ See /etc/udevil/udevil.conf for config.\n" );
//printf( "For automounting with udevil run 'devmon --help'\n" );
printf( "For automounting with udevil run 'devmon --help'\n" );
printf( "\n" );
}