Dodałem ukrywanie hasła (w ps aux), i obsluge dlugich nazw przelacznikow. Powinno dzialac, ale jakas mocno nie testowalem, bo jutro mam kolosa :)
Pozdrawiam i milego testowania.
Index: daemon/lmsd.c =================================================================== RCS file: /home/cvsroot/lms/daemon/lmsd.c,v retrieving revision 1.19 diff -u -r1.19 lmsd.c --- daemon/lmsd.c 11 Jun 2005 08:11:15 -0000 1.19 +++ daemon/lmsd.c 15 Jun 2005 23:11:22 -0000 @@ -25,6 +25,7 @@ #include <time.h> #include <stdlib.h> #include <unistd.h> +#include <getopt.h> #include <signal.h> #include <syslog.h> #include <stdio.h> @@ -384,10 +385,25 @@ { int opt; char revision[10]; + int option_index = 0; + const char* maska = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; + static struct option options[] = { + { "dbhost", 1, 0, 'h' }, + { "dbname", 1, 0, 'd' }, + { "dbuser", 1, 0, 'u' }, + { "dbpass", 1, 0, 'p' }, + { "hostname", 1, 0, 'H' }, + { "command", 2, 0, 'c' }, + { "reload", 0, 0, 'q' }, + { "foreground", 0, 0, 'f' }, + { "instance", 2, 0, 'i' }, + { "version", 0, 0, 'v' }, + { 0, 0, 0, 0 } + }; sscanf(REVISION, "$Id: lmsd.c,v %s", revision); - - while ( (opt = getopt(argc, argv, "qfvi:h:p:d:u:H:c:")) != -1 ) + + while ( (opt = getopt_long(argc, argv, "qfvi:h:p:d:u:H:c:", options, &option_index)) != -1 ) { switch (opt) { @@ -407,6 +423,7 @@ sscanf(optarg, "%[^:]:%d", host, &port); break; case 'p': + strncpy(argv[optind - 1], maska, sizeof(char)*(strlen(argv[optind - 1]))); passwd = optarg; break; case 'd': @@ -423,16 +440,17 @@ break; default: printf("LMS Daemon version 1.7-cvs (%s). Command line options:\n", revision); - printf(" -h host[:port]\t\tdatabase host (default: 'localhost')\n"); - printf(" -d db_name\t\tdatabase name (default: 'lms')\n"); - printf(" -u db_user\t\tdatabase user (default: 'lms')\n"); - printf(" -p password\t\tdatabase password (default: '')\n"); - printf(" -H daemon_host\t\thost name where runs daemon (default: `hostname`)\n"); - printf(" -c command\t\tshell command to run before database connecting\n\t\t\t(default: empty)\n"); - printf(" -q \t\t\tdo a reload and quit\n"); - printf(" -f \t\t\trun in foreground (don't fork)\n"); - printf(" -i "instance[ ...]"\tlist of instances to reload\n"); - printf(" -v \t\t\tprint version and copyright info\n"); + printf(" --dbhost -h host[:port]\tdatabase host (default: 'localhost')\n"); + printf(" --dbname -d db_name\t\tdatabase name (default: 'lms')\n"); + printf(" --dbuser -u db_user\t\tdatabase user (default: 'lms')\n"); + printf(" --dbpass -p password\t\tdatabase password (default: '')\n"); + printf(" --hostname -H daemon_host\thost name where runs daemon (default: `hostname`)\n"); + printf(" --command -c command\t\tshell command to run before database connecting\n\t\t\t\t(default: empty)\n"); + printf(" --reload -q \t\t\tdo a reload and quit\n"); + printf(" --foreground -f \t\trun in foreground (don't fork)\n"); + printf(" --instance -i "instance[ ...]"\tlist of instances to reload\n"); + printf(" --version -v \t\t\tprint version and copyright info\n"); + printf(" --help -h \t\t\tprint this text\n"); exit(1); } }