diff options
author | unknown <serg@serg.mysql.com> | 2002-10-25 21:15:52 +0000 |
---|---|---|
committer | unknown <serg@serg.mysql.com> | 2002-10-25 21:15:52 +0000 |
commit | f5563ddad40e8ab84d457b0e9960ddfdc7faec99 (patch) | |
tree | 30c13439b168df68d4884a7403a173a8970cc56e /sql/nt_servc.cc | |
parent | 68a5932ab2b5e39858fa03934cbbe5c90042497e (diff) | |
parent | 43abd169b081479cb6ce1ad510a2620a2bb50db8 (diff) | |
download | mariadb-git-f5563ddad40e8ab84d457b0e9960ddfdc7faec99.tar.gz |
merged
BitKeeper/etc/gone:
auto-union
BitKeeper/etc/logging_ok:
auto-union
BitKeeper/deleted/.del-skipkeys~53ffbfa7d2fa9fb:
Delete: BitKeeper/etc/skipkeys
BitKeeper/etc/skipkeys:
Rename: BitKeeper/deleted/.del-skipkeys~f623848ba4db5c3 -> BitKeeper/etc/skipkeys
Build-tools/Do-compile:
Auto merged
Docs/manual.texi:
Auto merged
innobase/pars/lexyy.c:
Auto merged
innobase/pars/pars0grm.c:
Auto merged
mysys/my_init.c:
Auto merged
scripts/mysqlhotcopy.sh:
Auto merged
sql/nt_servc.cc:
Auto merged
sql/nt_servc.h:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_table.cc:
Auto merged
mysql-test/t/bdb-crash.test:
Auto merged
Diffstat (limited to 'sql/nt_servc.cc')
-rw-r--r-- | sql/nt_servc.cc | 91 |
1 files changed, 90 insertions, 1 deletions
diff --git a/sql/nt_servc.cc b/sql/nt_servc.cc index 129df9864e2..2d0eae125d6 100644 --- a/sql/nt_servc.cc +++ b/sql/nt_servc.cc @@ -426,7 +426,17 @@ BOOL NTService::SeekStatus(LPCSTR szInternName, int OperationType) // open a connection to the SCM if (!(scm = OpenSCManager(0, 0,SC_MANAGER_CREATE_SERVICE))) - printf("There is a problem with the Service Control Manager!\n"); + { + DWORD ret_error=GetLastError(); + if (ret_error == ERROR_ACCESS_DENIED) + { + printf("Install/Remove of the Service Denied!\n"); + if(!is_super_user()) + printf("That operation should be made by an user with Administrator privileges!\n"); + } + else + printf("There is a problem for to open the Service Control Manager!\n"); + } else { if (OperationType == 1) @@ -507,3 +517,82 @@ BOOL NTService::got_service_option(char **argv, char *service_option) return TRUE; return FALSE; } +/* ------------------------------------------------------------------------ + -------------------------------------------------------------------------- */ +BOOL NTService::is_super_user() +{ + HANDLE hAccessToken; + UCHAR InfoBuffer[1024]; + PTOKEN_GROUPS ptgGroups=(PTOKEN_GROUPS)InfoBuffer; + DWORD dwInfoBufferSize; + PSID psidAdministrators; + SID_IDENTIFIER_AUTHORITY siaNtAuthority = SECURITY_NT_AUTHORITY; + UINT x; + BOOL ret_value=FALSE; + + if(!OpenThreadToken(GetCurrentThread(), TOKEN_QUERY, TRUE,&hAccessToken )) + { + if(GetLastError() != ERROR_NO_TOKEN) + return FALSE; + + if(!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hAccessToken)) + return FALSE; + } + + ret_value= GetTokenInformation(hAccessToken,TokenGroups,InfoBuffer, + 1024, &dwInfoBufferSize); + + CloseHandle(hAccessToken); + + if(!ret_value ) + return FALSE; + + if(!AllocateAndInitializeSid(&siaNtAuthority, 2, + SECURITY_BUILTIN_DOMAIN_RID, + DOMAIN_ALIAS_RID_ADMINS, + 0, 0, 0, 0, 0, 0, + &psidAdministrators)) + return FALSE; + + ret_value = FALSE; + + for(x=0;x<ptgGroups->GroupCount;x++) + { + if( EqualSid(psidAdministrators, ptgGroups->Groups[x].Sid) ) + { + ret_value = TRUE; + break; + } + + } + FreeSid(psidAdministrators); + return ret_value; +} +/* ------------------------------------------------------------------------ + -------------------------------------------------------------------------- */ +BOOL NTService::IsService(LPCSTR ServiceName) +{ + BOOL ret_value=FALSE; + SC_HANDLE service, scm; + + if (scm = OpenSCManager(0, 0,SC_MANAGER_ENUMERATE_SERVICE)) + { + if ((service = OpenService(scm,ServiceName, SERVICE_ALL_ACCESS ))) + { + ret_value=TRUE; + CloseServiceHandle(service); + } + CloseServiceHandle(scm); + } + return ret_value; +} +/* ------------------------------------------------------------------------ + -------------------------------------------------------------------------- */ +BOOL NTService::got_service_option(char **argv, char *service_option) +{ + char *option; + for (option= argv[1]; *option; option++) + if (!strcmp(option, service_option)) + return TRUE; + return FALSE; +} |