/* *********** Check comments starting with // ### and fill appropriate code there *********** */ #pragma implementation #include #include #include #include #include #include "updpass.h" #include "updpass.m" MODULE_DEFINE_VERSION(updpass); PUBLIC MODULE_updpass::MODULE_updpass() : LINUXCONF_MODULE("updpass") { linuxconf_loadmsg ("updpass",PACKAGE_REV); } PUBLIC int MODULE_updpass::dohtml (const char *key) { int ret = LNCF_NOT_APPLICABLE; if (strcmp(key,"updpass")==0){ // ### Insert any menu and dialog here ret = 0; } return ret; } static void usage() { xconf_error (MSG_U(T_USAGE ,"linuxconf --modulemain updpass usage\n" "\n" " No command line available for this module\n") ); } PUBLIC void MODULE_updpass::usage (SSTRINGS &tb) { tb.add (new SSTRING (MSG_R(T_USAGE))); } PUBLIC int MODULE_updpass::execmain (int argc , char *argv[], bool) { int ret = LNCF_NOT_APPLICABLE; const char *pt = strrchr(argv[0],'/'); if (pt != NULL){ pt++; }else{ pt = argv[0]; } if (strcmp(pt,"updpass")==0){ ret = -1; ::usage(); } return ret; } PUBLIC int MODULE_updpass::message (const char *msg, int argc, const char *argv[]) { int ret = LNCF_NOT_APPLICABLE; if (strcmp(msg,"chgpasswd")==0){ const char *script = "/etc/update-pass.sh"; if (!file_exist (script)){ xconf_error (MSG_U(E_NOSCRIPT,"Script %s does not exist\n" "Can't export the password"),script); }else{ const char *user = argv[0]; const char *passwd = argv[1]; const char *locked = argv[2]; const char *domain = argv[3]; char cmd[1000]; snprintf (cmd,sizeof(cmd)-1,"%s %s \"%s\" %s %s",script,user,passwd,locked,domain); POPEN pop (cmd); if (pop.isok()){ pop.wait (10); } } } return ret; } static MODULE_updpass updpass;