BSTR Cactive_pluginCtrl::SetRetValue(char *psz_ret) { CString strmac(psz_ret); return strmac.AllocSysString(); }
/* * main */ int main(int argc, char **argv) { int ch; int argcnt; int mac; /* integrity check mode, stdin */ actionf = CHECK | ST_IN; /* default values */ logfile = default_logfile; keyfile = default_keyfile; key0file = NULL; mac = 0; macfile = NULL; method = SHA1; argcnt = 1; /* skip program name */ while ((ch = getxopt(argc, argv, "f!logfile: g!generatekey" " i!initkeyfile: k!keyfile: l!mac m!method: q!quiet h!help", &argcnt)) != -1) { switch (ch) { case 'f': /* log file (intrusion detection mode) */ if (logfile != default_logfile) free(logfile); if ((logfile = strrealpath(argv[argcnt])) == NULL) { release(); perror(argv[argcnt]); exit(-1); } actionf &= ~ST_IN; break; case 'g': /* generate new keyfile and initial key */ actionf &= ~CHECK; break; case 'i': /* key 0 file */ if (key0file) free(key0file); if ((key0file = strdup(argv[argcnt])) == NULL) { release(); perror(argv[argcnt]); exit(-1); } break; case 'k': /* keyfile */ if (keyfile != default_keyfile) free(keyfile); if ((keyfile = strdup(argv[argcnt])) == NULL) { release(); perror(argv[argcnt]); exit(-1); } break; case 'l': mac = 1; break; case 'm': /* hash method */ if ( (method = gethash(argv[argcnt])) < 0) { release(); usage(); } break; case 'q': /* quiet mode */ actionf |= QUIET; break; case 'h': default: release(); usage(); } argcnt++; } /* check logfile specified without -f switch */ argc -= argc; argv += argc; if (argc && (actionf & ST_IN)) if ( (logfile = strrealpath(argv[argc-1])) == NULL) { release(); perror(argv[argc-1]); exit(-1); } /* if keyfile was not specified converted logfile is used instead */ if (keyfile == default_keyfile && logfile != default_logfile) { char *tmp; if ( (tmp = strallocat("/var/ssyslog/", logfile)) == NULL) { release(); perror("buffer for keyfile"); exit(-1); } strdot(tmp+13); if ( (keyfile = strallocat(tmp, ".key")) == NULL) { free(tmp); release(); perror("buffer for keyfile"); exit(-1); } free(tmp); } /* if key0file was not specified create one */ if (key0file == NULL) if ( (key0file = strkey0(keyfile)) == NULL) { release(); perror("creating key0 file"); exit(-1); } /* create macfile */ if (mac) if ( (macfile = strmac(keyfile)) == NULL) { release(); perror("creating mac file"); exit(-1); } /* execute action */ if (actionf & CHECK) check(); else generate(); release(); return (0); }