#pragma implementation #include #include #include "nisconf.h" #include "nisconf.m" #include #include #include MODULE_DEFINE_VERSION(nisconf); class DAEMON_YPBIND: public DAEMON_INTERNAL{ /*~PROTOBEG~ DAEMON_YPBIND */ public: int start (void); int startif (void); /*~PROTOEND~ DAEMON_YPBIND */ }; /* Start ypbind. */ PUBLIC int DAEMON_YPBIND::start () { int ret = 0; NIS_CONF nis; if (nis.set_domain() != -1){ const char *nisserver = nis.getserver(); if (nisserver != NULL){ #if 0 // The ypbind does not seems to be used anymore when // the NIS server is specified char buf[2000]; sprintf (buf,"%s -ypset %s",cmd.path.get(),cmd.args.get()); ret = -1; if (cmd.system (buf) == 0){ char ypset_path[PATH_MAX]; cmd.path.copy (ypset_path); char *pt = ypset_path + strlen(ypset_path) -1; while (pt >= ypset_path && *pt != '/') pt--; if (pt >= ypset_path && *pt == '/'){ *pt = '\0'; sprintf(buf,"%s/ypset %s",ypset_path,nisserver); }else{ sprintf(buf,"ypset %s",nisserver); } ret = cmd.system (buf); } #endif }else{ ret = DAEMON::start(); } } return ret; } /* Restart ypbind if ETC_DEFAULTDOMAIN is newer than the process */ PUBLIC int DAEMON_YPBIND::startif () { /* #Specification: ypbind / strategy ypbind is configured in the file /etc/conf.linuxconf It provides the nis domain and optionnally the nis server (If it can't be located by a broadcast). If the nis domain is defined, then ypbind is started. Depending if a server is specified or not, ypbind is started this way: # No specified NIS server ypbind With a specified NIS server ypbind -ypset ypset -h nisserver # If the configuration file is newer than the current process, it is killed and restarted. */ int ret = 0; NIS_CONF nis; int status = nis.check_domain(); if (status == -1){ ret = stop(); }else if (status == 0){ bool problem; if (findprocess(problem)==NULL) ret = start(); }else{ ret = restart(); } return ret; } static const char *keymenu=NULL; /* Update the YP database after a change in the user accounts */ static int nisconf_updyp() { int ret = 0; NIS_CONF conf; const char *domain = conf.getdomain(); if (conf.may_update() && domain[0] != '\0'){ ret = netconf_system_if ("nisconf_update",domain); } return ret; } ("nisconf",PACKAGE_REV); daemon_register (new DAEMON_YPBIND,"ypbind",""); tb.add (new SSTRING(MSG_U(T_USAGE ,"linuxconf --modulemain nisconf usage\n" "\n" " nisconf --option ...\n"))); if (context == MENU_NETWORK_CLIENT){ keymenu = MSG_U(M_nisconf,"Network Information System (NIS)"); dia.new_menuitem ("nis","",keymenu); } if (context == MENU_NETWORK_CLIENT){ if (key == keymenu){ nis_edit(); } } return 0; int ret = LNCF_NOT_APPLICABLE; if (strcmp(msg,"postdeluser")==0 || strcmp(msg,"newuser")==0 || strcmp(msg,"chguser")==0){ if (argc == 2 && strcmp(argv[1],"/")==0){ ret = nisconf_updyp(); } }else if (strcmp(msg,"postdelgroup")==0 || strcmp(msg,"newgroup")==0 || strcmp(msg,"chggroup")==0){ ret = nisconf_updyp(); }else if(strcmp(msg,"chgpasswd")==0){ if (argc == 4 && strcmp(argv[3],"/")==0){ ret = nisconf_updyp(); } } return ret; int ret = -1; if (argc == 1){ nis_edit(); }else{ printusage(); } return ret;