/*****************************************************************************\ * * * Name : run_as_service * * Author : Chris Koeritz * * * ******************************************************************************* * Copyright (c) 2000-$now By Author. This program is free software; you can * * redistribute it and/or modify it under the terms of the GNU General Public * * License as published by the Free Software Foundation; either version 2 of * * the License or (at your option) any later version. This is online at: * * http://www.fsf.org/copyleft/gpl.html * * Please send any updates to: fred@gruntose.com * \*****************************************************************************/ #include #include #include #include HOOPLE_STARTUP_CODE; ////////////// bool run_as_service(char *user, log_base &out) { #ifdef __WIN32__ // ensure that the user has the "logon as a service" right. nt_security secu; long err = secu.SetPrivilegeOnUser("", user, "SeServiceLogonRight", true); if (err) { // that didn't work; probably the user name is bad? out.log(astring(astring::SPRINTF, "There was a problem giving " "\"%s\" the \"Logon as a Service\" right:\r\n%s", user, critical_events::system_error_text(err).s())); return false; } #else astring junk = user; out.eol(); junk += ""; #endif return true; } int main(int argc, char *argv[]) { console_logger out; if (argc < 2) { out.log(filename(argv[0]).rootname() + " usage:\n\ The first parameter must be a user name that will be given the\n\ \"login as a service\" access rights.\n"); return 1; } bool did_it = run_as_service(argv[1], out); if (did_it) out.log(astring("Success giving \"") + argv[1] + "\" the 'login as service' rights."); else out.log(astring("Failed in giving \"") + argv[1] + "\" the 'login as service' rights!"); return !did_it; } #ifdef __BUILD_STATIC_APPLICATION__ // static dependencies found by buildor_gen_deps.sh: #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif // __BUILD_STATIC_APPLICATION__