📄 mslogonacl.cpp
字号:
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2004 Martin Scharpf. All Rights Reserved.
//
// 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 program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
//
// If the source code for the program is not available from the place from
// which you received this file, check
// http://ultravnc.sourceforge.net/
#include "MSLogonACL.h"
#include "vncImportACL.h"
#include "vncExportACL.h"
int main(int argc, char *argv[])
{
bool append = false;
int rc = 1;
if (argc > 1) {
if (stricmp(argv[1], "/i") == 0 || stricmp(argv[1], "-i") == 0) {
if (argc < 4) {
return 1;
} else {
if (stricmp(argv[2], "/a") == 0 || stricmp(argv[2], "-a") == 0)
append = true;
else if (stricmp(argv[2], "/o") == 0 || stricmp(argv[2], "-o") == 0)
; //override
else {
usage(argv[0]);
return 1;
}
if (!freopen(argv[3], "r", stdin)) {
printf("Error opening file %s", argv[3]);
usage(argv[0]);
return 1;
}
}
rc = import(append);
} else if (stricmp(argv[1], "/e") == 0 || stricmp(argv[1], "-e") == 0) {
if (argc > 2)
if (!freopen(argv[2], "w", stdout)) {
printf("Error opening file %s", argv[2]);
usage(argv[0]);
return 1;
}
rc = export();
} else {
usage(argv[0]);
}
} else {
usage(argv[0]);
}
return rc;
}
int
import(bool append){
int rc = 0;
vncImportACL importAcl;
PACL pACL = NULL; //?
if (append)
importAcl.GetOldACL();
if (importAcl.ScanInput())
rc |= 2;
pACL = importAcl.BuildACL();
importAcl.SetACL(pACL);
HeapFree(GetProcessHeap(), 0, pACL);
return rc;
}
int
export()
{
PACL pACL = NULL;
vncExportACL exportAcl;
exportAcl.GetACL(&pACL);
exportAcl.PrintAcl(pACL);
if (pACL)
LocalFree(pACL);
return 0;
}
void usage(const char *appname){
printf("Usage:\n%s /e <file>\n\t for exporting an ACL to an (optional) file.\n", appname);
printf("%s /i <mode> <file>\n\t for importing an ACL where mode is either\n", appname);
printf("\t/o for override or /a for append and file holds the ACEs.\n");
printf("For the format of the ACEs first configure some groups/users\n");
printf("with the graphical VNC Properties and then export the ACL.\n");
printf("The computer name can be replaced by a \".\" (a dot),\n");
printf("the computer's domain name by \"..\" (two dots).\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -