static retvalue set(const char *given, size_t len, bool newvalue, enum config_option_owner newowner) { int i; //TODO: allow multiple values sperated by some sign here... for (i = 0 ; i < IGN_COUNT ; i++) { if (strncmp(given, ignores[i], len) == 0 && ignores[i][len] == '\0') { if (owner_ignore[i] <= newowner) { ignore[i] = newvalue; owner_ignore[i] = newowner; } break; } } if (i == IGN_COUNT) { char *str = strndup(given, len); if (IGNORING(ignore, "Unknown --ignore value: '%s'!\n", (str!=NULL)?str:given)) { free(str); return RET_NOTHING; } else { free(str); return RET_ERROR; } } else return RET_OK; }
/** * @brief Sends a signal to a process. * * @param proc Process to send the signal. * @param sig Signal to be sent. */ PUBLIC void sndsig(struct process *proc, int sig) { /* * SIGCHLD and SIGCONT are somewhat special. The receiving * process is resumed even if these signals are being ignored, * otherwise caos might follow. */ if ((sig != SIGCHLD) && (sig != SIGCONT)) { if (IGNORING(proc, sig)) return; } /* Set signal flag. */ proc->received |= (1 << sig); /* Wake up process. */ if (proc->state == PROC_WAITING) { if (proc == *proc->chain) *proc->chain = proc->next; else { struct process *p; for (p = *proc->chain; p->next != proc; p = p->next) noop() ; p->next = proc->next; } sched(proc); } }
/** * parse_compat_threshold - Parse old deprecated pimd.conf thresholds * @line: * * This is a backwards compatible parser for the two older threshold * settings used in pimd prior to v2.2.0. The switchover mechanism has * been completely changed, however, so we simply read the settings as * if they where the same as the new spt_threshold, only converting the * rate argument differently (bps vs kbps). Last line to be read is * what is activated in pimd as spt-threshold. * * Note, previously the parser was very lenient to errors, but since the * default has changed it is much more strict. Any syntax error and pimd * bails out ignoring the line. * * Syntax: * switch_register_threshold [rate <BPS> interval <SEC>] * switch_data_threshold [rate <BPS> interval <SEC>] * * Returns: * When parsing @line is successful, returns %TRUE, otherwise %FALSE. */ static int parse_compat_threshold(char *line) { char *w; int rate = -1; int interval = -1; while (!EQUAL((w = next_word(&line)), "")) { if (EQUAL(w, "rate")) { if (EQUAL((w = next_word(&line)), "")) BAILOUT("Missing rate value in compat threshold parser"); /* 10 --> 1,000,000,000 == 100 Gbps */ if (sscanf(w, "%10d", &rate) != 1) BAILOUT("Invalid rate value %s in compat threshold parser", w); continue; } if (EQUAL(w, "interval")) { if (EQUAL((w = next_word(&line)), "")) IGNORING("Missing interval value in compat threshold parser"); /* 5 --> 99,999 ~= 27h */ if (sscanf(w, "%5d", &interval) != 1) IGNORING("Invalid interval %s in compat threshold parser", w); continue; } } /* Set polling mode */ spt_threshold.mode = SPT_RATE; /* Only accept values if they don't messup for new spt-threshold */ if (interval >= TIMER_INTERVAL) spt_threshold.interval = interval; /* Accounting for headers we can approximate 1 byte/s == 10 bits/s (bps) */ spt_threshold.bytes = rate * spt_threshold.interval / 10; logit(LOG_INFO, 0, "Compatibility set spt-treshold rate %u kbps with interval %u sec", spt_threshold.bytes, spt_threshold.interval); return TRUE; }
/** * @brief Sends a signal to a process. * * @param proc Process to send the signal. * @param sig Signal to be sent. */ PUBLIC void sndsig(struct process *proc, int sig) { /* Ignore this. */ if (IGNORING(proc, sig) && (sig != SIGCHLD)) return; /* Set signal flag. */ proc->received |= (1 << sig); /* * SIGCONT is somewhat special. The receiving process * is resumed even if SIGCONT is being ignored, * otherwise it could stop forever. */ if (sig == SIGCONT) { resume(proc); /* * The process is not catching SIGCONT and the * default action for this signal has just been * taken. */ if (!CATCHING(proc, sig)) { proc->received &= ~(1 << sig); return; } } /* Wake up process. */ if (proc->state == PROC_WAITING) { if (proc == *proc->chain) *proc->chain = proc->next; else { struct process *p; for (p = *proc->chain; p->next != proc; p = p->next) noop() ; p->next = proc->next; } sched(proc); } }
retvalue deb_prepare(/*@out@*/struct debpackage **deb, component_t forcecomponent, architecture_t forcearchitecture, const char *forcesection, const char *forcepriority, packagetype_t packagetype, struct distribution *distribution, const char *debfilename, const char * const givenfilekey, const struct checksums * checksums, const struct strlist *allowed_binaries, const char *expectedsourcepackage, const char *expectedsourceversion){ retvalue r; struct debpackage *pkg; const struct overridedata *oinfo; char *control; struct atomlist forcearchitectures; assert (givenfilekey != NULL); assert (checksums != NULL); assert (allowed_binaries != NULL); assert (expectedsourcepackage != NULL); assert (expectedsourceversion != NULL); /* First taking a closer look in the file: */ r = deb_read(&pkg, debfilename, true); if (RET_WAS_ERROR(r)) { return r; } if (!strlist_in(allowed_binaries, pkg->deb.name) && !IGNORING(surprisingbinary, "'%s' has packagename '%s' not listed in the .changes file!\n", debfilename, pkg->deb.name)) { deb_free(pkg); return RET_ERROR; } if (strcmp(pkg->deb.source, expectedsourcepackage) != 0) { /* this cannot be ignored easily, as it determines * the directory this file is stored into */ fprintf(stderr, "'%s' lists source package '%s', but .changes says it is '%s'!\n", debfilename, pkg->deb.source, expectedsourcepackage); deb_free(pkg); return RET_ERROR; } if (strcmp(pkg->deb.sourceversion, expectedsourceversion) != 0 && !IGNORING(wrongsourceversion, "'%s' lists source version '%s', but .changes says it is '%s'!\n", debfilename, pkg->deb.sourceversion, expectedsourceversion)) { deb_free(pkg); return RET_ERROR; } forcearchitectures.count = 1; forcearchitectures.size = 1; forcearchitectures.atoms = &forcearchitecture; r = deb_preparelocation(pkg, forcecomponent, &forcearchitectures, forcesection, forcepriority, packagetype, distribution, &oinfo, debfilename); if (RET_WAS_ERROR(r)) { deb_free(pkg); return r; } if (strcmp(givenfilekey, pkg->filekey) != 0) { fprintf(stderr, "Name mismatch: .changes indicates '%s', but the file itself says '%s'!\n", givenfilekey, pkg->filekey); deb_free(pkg); return RET_ERROR; } /* Prepare everything that can be prepared beforehand */ r = binaries_complete(&pkg->deb, pkg->filekey, checksums, oinfo, pkg->deb.section, pkg->deb.priority, &control); if (RET_WAS_ERROR(r)) { deb_free(pkg); return r; } free(pkg->deb.control); pkg->deb.control = control; *deb = pkg; return RET_OK; }