Rename the low-level NCP wrapper functions in ncpcall.c and net.h to include both the NCP function/subfunction number and the operation they perform. This keeps the numeric protocol reference visible for comparison with SDK documentation and MARS-NWE logs, while making call sites easier to understand. Update all callers to use the new names. No behavior change.
161 lines
4.2 KiB
C
161 lines
4.2 KiB
C
/*
|
|
* mars-nwe-dosutils - NetWare/DOS utility tools.
|
|
*
|
|
* Copyright (C) 2026 Mario Fetka
|
|
*
|
|
* 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, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/*
|
|
* Purpose: Shared trustee and rights helper implementation for GRANT, REMOVE and REVOKE style tools.
|
|
* Depends on: net.h, trustee.h, c32ncp.h callers, netcall.c requester helpers, tools.c shared utility routines.
|
|
*/
|
|
|
|
#include "net.h"
|
|
#include "trustee.h"
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
|
|
#ifndef S_IFDIR
|
|
#define S_IFDIR 0040000
|
|
#endif
|
|
|
|
|
|
|
|
|
|
int trustee_is_subdirs_option(char *s)
|
|
{
|
|
if (!s) return(0);
|
|
return(tool_strsame(s, "/SUBDIRS") || tool_strsame(s, "-SUBDIRS") ||
|
|
tool_strsame(s, "/SUBDIRECTORIES") || tool_strsame(s, "-SUBDIRECTORIES") ||
|
|
tool_strsame(s, "/S") || tool_strsame(s, "-S"));
|
|
}
|
|
|
|
int trustee_is_files_option(char *s)
|
|
{
|
|
if (!s) return(0);
|
|
return(tool_strsame(s, "/FILES") || tool_strsame(s, "-FILES") ||
|
|
tool_strsame(s, "/F") || tool_strsame(s, "-F"));
|
|
}
|
|
|
|
int trustee_parse_right_word(char *s, uint16 *rights)
|
|
{
|
|
if (tool_strsame(s, "ALL")) {
|
|
*rights = TRUSTEE_RIGHT_ALL_386;
|
|
return(0);
|
|
}
|
|
|
|
if (tool_strsame(s, "N") || tool_strsame(s, "NONE")) {
|
|
*rights = TRUSTEE_RIGHT_ALL_386;
|
|
return(0);
|
|
}
|
|
|
|
if (tool_strsame(s, "S") || tool_strsame(s, "SUPERVISOR")) {
|
|
*rights |= TRUSTEE_RIGHT_SUPER;
|
|
return(0);
|
|
}
|
|
|
|
if (tool_strsame(s, "R") || tool_strsame(s, "READ")) {
|
|
*rights |= TRUSTEE_RIGHT_READ;
|
|
return(0);
|
|
}
|
|
|
|
if (tool_strsame(s, "W") || tool_strsame(s, "WRITE")) {
|
|
*rights |= TRUSTEE_RIGHT_WRITE;
|
|
return(0);
|
|
}
|
|
|
|
if (tool_strsame(s, "C") || tool_strsame(s, "CREATE")) {
|
|
*rights |= TRUSTEE_RIGHT_CREATE;
|
|
return(0);
|
|
}
|
|
|
|
if (tool_strsame(s, "E") || tool_strsame(s, "ERASE") ||
|
|
tool_strsame(s, "D") || tool_strsame(s, "DELETE")) {
|
|
*rights |= TRUSTEE_RIGHT_DELETE;
|
|
return(0);
|
|
}
|
|
|
|
if (tool_strsame(s, "M") || tool_strsame(s, "MODIFY")) {
|
|
*rights |= TRUSTEE_RIGHT_MODIFY;
|
|
return(0);
|
|
}
|
|
|
|
if (tool_strsame(s, "F") || tool_strsame(s, "FILESCAN") ||
|
|
tool_strsame(s, "FILE") || tool_strsame(s, "SCAN")) {
|
|
*rights |= TRUSTEE_RIGHT_SEARCH;
|
|
return(0);
|
|
}
|
|
|
|
if (tool_strsame(s, "A") || tool_strsame(s, "ACCESS") ||
|
|
tool_strsame(s, "CONTROL") || tool_strsame(s, "ACCESSCONTROL")) {
|
|
*rights |= TRUSTEE_RIGHT_OWNER;
|
|
return(0);
|
|
}
|
|
|
|
return(-1);
|
|
}
|
|
|
|
void trustee_rights_bracket(uint16 rights, char *out)
|
|
{
|
|
out[0] = (rights & TRUSTEE_RIGHT_SUPER) ? 'S' : ' ';
|
|
out[1] = (rights & TRUSTEE_RIGHT_READ) ? 'R' : ' ';
|
|
out[2] = (rights & TRUSTEE_RIGHT_WRITE) ? 'W' : ' ';
|
|
out[3] = (rights & TRUSTEE_RIGHT_CREATE) ? 'C' : ' ';
|
|
out[4] = (rights & TRUSTEE_RIGHT_DELETE) ? 'E' : ' ';
|
|
out[5] = (rights & TRUSTEE_RIGHT_MODIFY) ? 'M' : ' ';
|
|
out[6] = (rights & TRUSTEE_RIGHT_SEARCH) ? 'F' : ' ';
|
|
out[7] = (rights & TRUSTEE_RIGHT_OWNER) ? 'A' : ' ';
|
|
out[8] = '\0';
|
|
}
|
|
|
|
uint32 trustee_lookup_object(char *name, uint16 *objtype, int objtype_given)
|
|
{
|
|
uint8 namebuf[48];
|
|
uint32 object_id;
|
|
|
|
strmaxcpy(namebuf, name, sizeof(namebuf) - 1);
|
|
upstr(namebuf);
|
|
|
|
if (objtype_given) {
|
|
return(ncp17_35_get_bindery_object_id(namebuf, *objtype));
|
|
}
|
|
|
|
*objtype = TRUSTEE_BINDERY_USER;
|
|
object_id = ncp17_35_get_bindery_object_id(namebuf, TRUSTEE_BINDERY_USER);
|
|
if (object_id)
|
|
return(object_id);
|
|
|
|
*objtype = TRUSTEE_BINDERY_GROUP;
|
|
object_id = ncp17_35_get_bindery_object_id(namebuf, TRUSTEE_BINDERY_GROUP);
|
|
return(object_id);
|
|
}
|
|
|
|
int trustee_path_is_dir(char *path)
|
|
{
|
|
struct stat st;
|
|
|
|
if (!path || !*path || tool_strsame(path, ".") || tool_strsame(path, ".\\") ||
|
|
tool_strsame(path, "./"))
|
|
return(1);
|
|
|
|
if (stat(path, &st) == 0) {
|
|
if (st.st_mode & S_IFDIR)
|
|
return(1);
|
|
}
|
|
|
|
return(0);
|
|
}
|
|
|