jcnelson / vdev

A device-file manager for *nix
GNU General Public License v3.0
101 stars 13 forks source link

unrecognized option '--help' #99

Closed PeteGozz closed 7 years ago

PeteGozz commented 8 years ago

While this "bug" is not a show stopper ...

 1.  System ex Debian testing / sid  now Devuan jessie / ascii 
 2.  Installed as per how-to-test  docs. 
 3.  running the following spits a helpful  error

~/sources/vdev$ ./build/sbin/vdevd --help

./build/sbin/vdevd: unrecognized option '--help'

Unrecognized option -?
02305:00000000B7514700: [          vdev.c:0932] vdev_init: ERROR: vdev_config_load_from_argv rc = -1
Usage: ./build/sbin/vdevd [options] mountpoint
Options include:

   -c, --config-file CONFIG_FILE
                  Path to the config file to use.

   -v, --verbose-level VERBOSITY
                  Set the level of verbose output.  Valid values are
                  positive integers.  Larger integers lead to more
                  debugging information.

   -l, --log-file LOGFILE_PATH
                  Path to which to log information.
                  Pass 'syslog' to log to syslog, instead of a logfile.

   -1, --once
       --coldplug-only
                  Exit once all extant devices have been processed.

   -f, --foreground
                  Run in the foreground; do not daemonize.

   -p, --pidfile PATH
                  Write the PID of the daemon to PATH.
02305:00000000B7514700: [          main.c:0053] main: ERROR: vdev_init rc = -1

I've probably missed something obvious., though as I actually RTFM(s) and followed the instructions I'm calling this a bug .

suedi commented 8 years ago

If you check the info text printed in your error you see that "--help" is not implemented

This is default behavior. If vdevd finds an unrecognized argument it generates an error and spits out "help"-text. "--help" is an unrecognized argument.

The actual parsing is done in libvdev/config.c-->vdev_config_load_from_args( ... ) if you want to check it out.

I agree that --help should be implemented and it would be rather trivial to add it.

PeteGozz commented 8 years ago

Thanks suedi. Its not a showstopper at this stage. Perhaps the issue is actually with the how-to-test docs . e.g. As I read there that --help was impemented I assumed I had missed something in the build / dependencies process. (which was not the case )

I am going to install a clean devuan over the next few days. (and lose some years of um "clutter" on my very bent debian) Then maybe I can add something sensible and usefull.

FWIW. I have vdevd running reasonably well on a debian > devuan . Have permission issues with normal users starting X . peraps a logind or cgroup/manage thing .. (systemd >< um related intricacies ((perhaps))) Also some ordering dependency problems around a wireless driver loading ... almost all are easily got around though, um a little hairy.

Not directly vdevd related either !

A fresh build may add clarity . (and will not hurt)

suedi commented 8 years ago

Sounds like good ideas all around.

Is it your intention to create a devuan/debian package?

Please post results of your endeavor

PeteGozz commented 8 years ago

I hope to contribute to smoothing out vdev if I can. I don't have access to enough different systems to build a package.

Just now finished another old laptop and my desktop to vanilla devuan jessie/ascii (already have some ascii ) which went smoothly enough.

I have yet to investigate a new build ... first some sleep :)

PeteGozz commented 7 years ago

So ah um.. Accidentally and unintentionally built vdev and (the oops bit )installed on my just "spent a day rebuilding" desktop . And learnt some stuff the hard way.

The X lockout {drop keyboard and mouse input } is not directly related to vdev (or arguably even udev) but init nonsense, assumption etc .
My solution is possibly more brutal than required --

1.  make uninstall (in ///vdev)
   (rerun make >> install  if you have to)

2.  reinstall the _Devuan_ udev  by which I also assumes you have pinned out systemd )
     - Commandline: apt-get install --reinstall udev
     - Reinstall: udev:i386 (215-17+deb8u4)

3. grab a copy of MAKEDEV   (its a package) 
    hand run that in /dev 

4. finally  wrote an extra init script that ensures 
    - the console gets set up and  that 
    - X  gets its basic tmp stuff built. (if required)  
       (by calling the existing init scripts)

At some point it all started reliably working again. ... can get a GUI from startx or from slim display manager with openbox.

Here is a copy of the rough init.d script

#!/bin/sh
## snipped ##
### BEGIN INIT INFO
# Provides:          keyboard
# Required-Start:    $local_fs 
# Required-Stop:     
# Default-Start:     S 2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: nasty hack
# Description:       try to force a keyboard and basic X

### END INIT INFO

# Author: Petes.really.pissedoff <pete@his.host>
#
DESC="Nasty Hack to force a keyboard and simple X"
#DAEMON=/usr/local/sbin/forcexkeys.bash
/etc/init.d/console-setup restart || printf "maybe we dont need this anyway"  
/etc/init.d/x11-common    start || /etc/init.d/x11-common    restart 

if [ -e /dev/input/mouse* ] || [ -e /dev/input/mice ]; then
 #   ls /dev/input
    printf "here there be mices "
else
    printf  "desperately seeking mices"
    cd /dev 
    /sbin/MAKEDEV input || true
    /sbin/MAKEDEV usb   || true
    cd /
    /bin/true 
fi

exit 0

Hopefully this may help somebody else. oh um I was rebuilding to track deps .. never mind .. just careless and distracted ...

suedi commented 7 years ago

Much appcreciated your sharing but am I right in assuming you are not running vdev at the end there?

It's more like a static dev nodes setup?

I also tried running vdev on devuan but also got the same result mouse, keyboard locked out.

PeteGozz commented 7 years ago

Yes I had to back out vdev. Which is certainly not my objective :)

I can break the X startup with and without vdev :) So its something else. Sometimes the logs help sometimes they are silent. My thought (guess) today , is that

Design wise I can see no reason NOT to have a static dev (aka MAKEDEV) with vdev running hotplug events but then that's probably because I haven't seen all of the hotplug world yet. ;>

There are in any case many many more side effects than I consider sane ... None of this is really an issue with vdev, other than its not part of the party . i.e. It may be that the systemd+udev merge and ooze is breaking way more than even the poor design intended. Looks like anything that runs a service/daemon or a socket in user space is captured... ( Or at least that seems to be an intent) e.g. I can not install erlang because it now need libsystemd nonsense (yeah like a hole on the head).

Apologies I am just "thinking" out loud really, and with no great clarity !.

I am now thinking I need to delve into the vdev source more deeply :) and perhaps look at the systemd-shim packages etc.

Otherwise its essentially build every daemon from scratch or something ... Which may not be as silly or difficult as it sounds.

Also the initrd scripts um break on boots ... (though I can just skip them and thats another thread ! )

rofl0r commented 7 years ago

@PeteGozz the issues you describe i usually experience when the X user doesn't have sufficient privs, which in my distro i solve doing

        # if mdev/eudev don't work as excepted, do it straight                  
        chown root:audio /dev/snd/* && chmod 0660 /dev/snd/*                    
        chown root:video /dev/fb0 && chmod 0660 /dev/fb0                        
        chown root:tty /dev/tty && chmod 0666 /dev/tty                          
        [ -e /dev/kvm ] && chown root:kvm /dev/kvm && chmod 0660 /dev/kvm       
        chmod og+r /dev/rtc0                                                    

(note that the user has to be in those groups)

PeteGozz commented 7 years ago

@rofl0r In the case where I can run X as root or login only works via a Display manager. the approach you outline is certainly the go. (though I never touched kvm ... ) Sometimes root can't even start up without a lockout. I've even had ssh access snapped shut.

Next time I have the issue I will chmod(s) as you suggest. Its also probably why the MAKEDEV run fixed things. (as it sets similar if the head of that script is correct) I am sure I will run into this again.

FWIW I was trying to run debian and devuan (on separate hardware ) It's too confusing. So for now I will simply reference other working systems for guidance.

Thanks for the confirmation though. How we get to needing that run is also a question on a fresh install.

suedi commented 7 years ago

Is it possible, for experimentation, to run vdev as root i.e. like Xorg wrapper?

I have had some issus running vdev together with devtmpfs and reported it here so maybe some trouble there?

FYI I have a vdev running on an arch derivative.

I run busybox-->mdev() in initramfs then swith to vdev. This works well X is run as root though.

Mr. Nelson also has vdev running but I am not sure in exactly what configuration.

PeteGozz commented 7 years ago

@suedi I intend to keep experimenting and maybe one day I can package vdevd (and friends) for devuan and possibly debian. Its very close though still alpha .

I will be posting my idea of --help fix today / soon The busybox approach must be a brilliant idea as I also want to try it :) I note the project intents around being portable as well.

As far as the builds go here the /dev/ structure looks excellent. Everything is as it should be.

So after this --help thing I was thinking of trekking through initrd world as that seems like the most likely place for things to go astray. It probably something silly ((it usually is)) and screamingly obvious to chaps who write bootloaders and such!

My C etal is getting a much needed update ;>

PeteGozz commented 7 years ago

Patches for vdevd --help and -h There are 4 files effected I will upload someplace as a tar.gz of patches only meantime see next 4 posts

PeteGozz commented 7 years ago
--- vdev.c.orig 2016-07-27 16:09:48.244999006 +0930
+++ vdev.c      2016-07-27 12:13:42.128962610 +0930
@@ -1,5 +1,5 @@
 /*
-   vdev: a virtual device manager for *nix
+   Vdev: A virtual device manager for *nix
    Copyright (C) 2014  Jude Nelson

    This program is dual-licensed: you can redistribute it and/or modify
@@ -926,6 +926,14 @@

    // parse config options from command-line 
    rc = vdev_config_load_from_args( vdev->config, argc, argv, NULL, NULL );
+   // help is not an error
+   if( rc == -2 ) {
+
+     vdev_config_usage( argv[0] );
+
+     return 0;
+     
+   }

    if( rc != 0 ) {
PeteGozz commented 7 years ago

--- main.c.original     2016-07-27 16:52:28.665005584 +0930
+++ main.c      2016-07-27 12:05:12.396961300 +0930
@@ -32,29 +32,40 @@

 // run! 
 int main( int argc, char** argv ) {
-   
-   int rc = 0;
-   int coldplug_quiesce_pipe[2];
-   bool is_child = false;
-   bool is_parent = false;
-   ssize_t nr = 0;

-   int coldplug_finished_fd = -1;   // FD to write to once we finish flushing the
 initial device requests
-   
-   memset( &vdev, 0, sizeof(struct vdev_state) );
-   
-   // ignore SIGPIPE from daemonlets 
-   signal( SIGPIPE, SIG_IGN );
-   
-   // set up global vdev state
-   rc = vdev_init( &vdev, argc, argv );
-   if( rc != 0 ) {
-      
-      vdev_error("vdev_init rc = %d\n", rc );
+  int rc = 0;
+  int coldplug_quiesce_pipe[2];
+  bool is_child = false;
+  bool is_parent = false;
+  ssize_t nr = 0;
+  
+  int coldplug_finished_fd = -1;   // FD to write to once we finish flushing the initial device requests
+  
+  memset( &vdev, 0, sizeof(struct vdev_state) );
+  
+  // ignore SIGPIPE from daemonlets 
+  signal( SIGPIPE, SIG_IGN );
+  
+  // set up global vdev state
+  rc = vdev_init( &vdev, argc, argv );
+  // help called from command line -h or --help (-2)
+  // short circuit with log/debug support
+  if( vdev.config->help ){
+    if( rc == -2 ){

-      vdev_shutdown( &vdev, false );
-      exit(1);
-   }
+      vdev_debug("%s", "exiting: help called at command line\n");
+      // the shutdown and clean up should be redundant ?      
+      exit(0);
+    }
+  }
+  
+  if( rc != 0 ) {
+    
+    vdev_error("vdev_init rc = %d\n", rc );
+    
+    vdev_shutdown( &vdev, false );
+    exit(1);
+  }

    // run the preseed command 
    rc = vdev_preseed_run( &vdev );
PeteGozz commented 7 years ago

--- config.h.orig       2016-07-27 15:32:17.284993223 +0930
+++ config.h    2016-07-27 11:40:43.248957526 +0930
@@ -42,6 +42,7 @@
 #define VDEV_CONFIG_COLDPLUG_ONLY "coldplug_only"
 #define VDEV_CONFIG_FOREGROUND    "foreground"
 #define VDEV_CONFIG_PRESEED       "preseed"
+#define VDEV_CONFIG_HELP          "help"              // simple commandline help

 #define VDEV_CONFIG_INSTANCE_NONCE_LEN 32
 #define VDEV_CONFIG_INSTANCE_NONCE_STRLEN (2*VDEV_CONFIG_INSTANCE_NONCE_LEN + 1)
@@ -104,6 +105,9 @@

    // bitfield of OS-specific quirks 
    uint64_t OS_quirks;
+
+  //  help holder
+  char help;
 };

 C_LINKAGE_BEGIN
@@ -112,7 +116,6 @@
 int vdev_config_load( char const* path, struct vdev_config* conf );
 int vdev_config_load_file( FILE* file, struct vdev_config* conf );
 int vdev_config_free( struct vdev_config* conf );
-
 int vdev_config_usage( char const* progname );
 int vdev_config_load_from_args( struct vdev_config* config, int argc, char** argv, int* fuse_argc, char** fuse_argv );
 int vdev_config_fullpaths( struct vdev_config* config );
PeteGozz commented 7 years ago

--- config.c.orig   2016-07-27 15:32:00.000993178 +0930
+++ config.c    2016-07-27 15:18:43.528991132 +0930
@@ -487,9 +487,12 @@
                   \n\
    -p, --pidfile PATH\n\
                   Write the PID of the daemon to PATH.\n\
+   -h, --help\n\
+                  prints this help message.\n\
+                  and exits early.\n\
 ", progname );

-  return 0;
+   return 0;  
 }

 // get the mountpoint option, by taking the last argument that wasn't an optarg
@@ -528,6 +531,7 @@
       {"once",            no_argument,         0, '1'},
       {"coldplug-only",   no_argument,         0, 'n'},
       {"foreground",      no_argument,         0, 'f'},
+      {"help",            no_argument,         0, 'h'},
       {0, 0, 0, 0}
    };

@@ -536,7 +540,7 @@
    int c = 0;
    int fuse_optind = 0;

-   char const* optstr = "c:v:l:o:f1np:ds";
+   char const* optstr = "c:v:l:o:hf1np:ds";

    if( fuse_argv != NULL ) { 
        fuse_argv[fuse_optind] = argv[0];
@@ -546,8 +550,8 @@
    while(rc == 0 && c != -1) {

       c = getopt_long(argc, argv, optstr, vdev_options, &opt_index);
-      
-      if( c == -1 ) {
+      // break on -1 missing  arguments and -2 help
+      if( c == -1 || c == -2 ) {
          break;
       }

@@ -650,6 +654,13 @@

             break;
          }
+      
+      case 'h': {
+   // command args line help
+   fprintf(stderr, "Command Line Options Help \n" );
+   rc = -2; 
+   break;
+      }

          default: {
PeteGozz commented 7 years ago

applied order is not important the files are in vdevd and libvdevd something like

patch --dry-run -b --verbose target.x yourpastedcontent.target.x.patch

make clean etc

build/sbin/vdevd --help

startling aint it :)

PeteGozz commented 7 years ago

https://drive.google.com/open?id=0B6DOd-QcjJNNaS1vOENucjZNZ3M should get you a tarball with all of that in a directory like so:

tar zxvf vdev-help-patches-27july2016.tar.gz 
vdev-help-patches-27july2016/
vdev-help-patches-27july2016/libvdev-config.c.patch
vdev-help-patches-27july2016/vdevd-vdev.c.patch
vdev-help-patches-27july2016/libvdev-config.h.patch
vdev-help-patches-27july2016/vdevd-main.c.patch
vdev-help-patches-27july2016/README
fbt commented 7 years ago

Why not make a pull request?

PeteGozz commented 7 years ago

Yeah I should set all that up (fork etc) I wasn't really expecting to go as far as I did.

PeteGozz commented 7 years ago

Ok all set up and pull request made

suedi commented 7 years ago

Good Job!

PeteGozz commented 7 years ago

Thanks @suedi I will try to work in the initrd / deployment areas next. Though I can see no obvious error :)

PeteGozz commented 7 years ago

FWIW I have uploaded much of the explorations I made over the last weeks over on my fork. These all seem to build and install OK here.

i.e. Vdevd works OK for at least my simple laptop and desktop needs. (you will need probably to tweak the init scripts and confs.)

While it can be installed into an initramfs image MAKEDEV may be a saner approach. YMMV.

My next target was to ensure PID and log files are correctly set depending on iniramfs or final system. That seems to cause issues.

Also I was making a start on some documentation for the conf file... Which resolve to the debugging level.

Not sure if I should bother though really.

The more important work is probably the libs (both types) though unfortunately keeping these lined up with Debian (systemd) and the now creeping depends on libsystemd merged with udev ...

... Just random thoughts really ...

suedi commented 7 years ago

Yeah,

Well you decide but I am glad that you share your findings

PeteGozz commented 7 years ago

@suedi
I decided to have a look at the source code for xorg-common (from debian/devuan sources) It may be that the mouse and keyboard lockout happens when systemd-logind isn't there. Um I assumed the devuan chaps would be onto this.

So A quick browse of the Linux specific code would seem to have systemd breakages (if your not using systemd) all over the place.

I'll try to build and run Xorg from the debian sources as it may not be too hard as there are still option in configure to NOT enable systemd support.

Sorry my point is that it would seem that the Xorg sources has defaulted to full systemd (and the rest of the ... ) so maybe a build with out the stuff will work

I will report back here with any results. (may take a while its a reasonably complex install to break / install and dep tree to build) :)

suedi commented 7 years ago

Hey man

I dont know if you read the DNG mailing list of devuan.

Right know there is an effort to make vdev run on devuan. It seems they got mouse and keyboard working om devuan using vdev.

Check out https://lists.dyne.org/lurker/search/20380101.000000.00000000@ml:dng,vdev.en.html

I think the problem came down to: if you turned off udev you have to have a working vdev in initramsfs

PeteGozz commented 7 years ago

On Mon, 15 Aug 2016 12:12:10 -0700 suedi notifications@github.com wrote:

Hey man

I dont know if you read the DNG mailing list of devuan.

Right know there is an effort to make vdev run on devuan. It seems they got mouse and keyboard working om devuan using vdev.

Check out https://lists.dyne.org/lurker/search/20380101.000000.00000000@ml:dng,vdev.en.html

I think the problem cam down to: if you turned off udev you have to have a working vdev in initramsfs

OH I just knew it :) Excellent.

Thank you very much.

Also fwiw building X is a pain, there is all this broken awk way down deep in the build process.

As for the working in initramfs ... Sure hmm um OK but this is not supposed to be required .

Hey, so I'm off to see the wizards :) (and subscribe to that list)

-- Peter Gossner gossner@internode.on.net Pete pete.gossner@gmail.com Tuesday 16 August 09:50:41 ACST 2016

suedi commented 7 years ago

... the wonderful wizards of devuan :-)

(When you think this issue is in some way was solved for you, will you please close it)

because because because because becaaaaause because of the wonderful things they does

PeteGozz commented 7 years ago

Sure. I reckon here is a good place to halt this thread.