+static MODCMD_FUNC(cmd_setdevnull) {
+ struct handle_info *hi;
+ if (!(hi = user->handle_info)) {
+ reply("NSMSG_MUST_AUTH");
+ return 0;
+ }
+ struct hs_fakehost_info fhinfo = parse_fakehost_info(argv[1], 1);
+ if(fhinfo.parse_state == HS_FHPARSE_INVALID) {
+ reply("HSMSG_TOPLEVEL_INVALID", argv[1]);
+ return 0;
+ }
+ if(!fhinfo.have_secondlevel) {
+ reply("HSMSG_FAKEHOST_TLDEVNULL");
+ return 0;
+ } else {
+ if(!fhinfo.tlfh) {
+ reply("HSMSG_UNKNOWN_FAKEHOST", fhinfo.slfh_name, fhinfo.tlfh_name);
+ return 0;
+ }
+ if(!check_management_access(hi, NULL, NULL)) {
+ reply("HSMSG_ACCESS_DENIED");
+ return 0;
+ }
+ char *fakehost_name;
+ if(!strcmp(argv[2], "*")) {
+ fhinfo.slfh->devnull_id = 0;
+ fakehost_name = "-";
+ } else {
+ struct devnull_class *th = devnull_find_name(argv[2]);
+ if(!th) {
+ reply("OSMSG_DEVNULL_NOTFOUND", argv[2]);
+ return 0;
+ }
+ fhinfo.slfh->devnull_id = th->id;
+ fakehost_name = th->name;
+ }
+ reply("HSMSG_DEVNULL_CLASS", fhinfo.slfh_name, fhinfo.tlfh_name, fakehost_name);
+ }
+ return 1;
+}
+
+
+struct devnull_class hostserv_get_user_priv(struct handle_info *hi) {
+ struct devnull_class th;
+ memset(&th, 0, sizeof(th));
+
+ struct hs_user *huser = hs_get_user(hi, 0);
+ if(huser) {
+ struct devnull_class *devc;
+ if(hi->devnull_id != 0) {
+ devc = devnull_find_id(huser->hi->devnull_id);
+ if(devc) {
+ if(DEVNULL_HAS_PRIV(devc, CHANLIMIT) && (!DEVNULL_HAS_PRIV(&th, CHANLIMIT) || th.maxchan < devc->maxchan))
+ th.maxchan = devc->maxchan;
+ if(DEVNULL_HAS_PRIV(devc, MAXSENDQ) && (!DEVNULL_HAS_PRIV(&th, MAXSENDQ) || th.maxsendq < devc->maxsendq))
+ th.maxsendq = devc->maxsendq;
+ th.modes |= devc->modes;
+ if(!th.name)
+ th.name = devc->name;
+ }
+ } else {
+ struct hs_assignment *assignment;
+ struct hs_secondlevel *slfh;
+ for(assignment = huser->assignments; assignment; assignment = assignment->unext) {
+ slfh = assignment->secondlevel;
+ if(slfh->devnull_id) {
+ devc = devnull_find_id(slfh->devnull_id);
+ if(!devc) {
+ slfh->devnull_id = 0;
+ continue;
+ }
+ if(DEVNULL_HAS_PRIV(devc, CHANLIMIT) && (!DEVNULL_HAS_PRIV(&th, CHANLIMIT) || th.maxchan < devc->maxchan))
+ th.maxchan = devc->maxchan;
+ if(DEVNULL_HAS_PRIV(devc, MAXSENDQ) && (!DEVNULL_HAS_PRIV(&th, MAXSENDQ) || th.maxsendq < devc->maxsendq))
+ th.maxsendq = devc->maxsendq;
+ th.modes |= devc->modes;
+ if(!th.name)
+ th.name = devc->name;
+ }
+ }
+ }
+ }
+ return th;
+}
+