trustee: share trustee header path formatting

Move the shared GRANT/REMOVE/REVOKE header path formatting into trustee.c.

The Novell trustee tools display the server and volume separator as
SERVER/SYS: while keeping the remaining path separators as DOS backslashes.
Use one trustee_header_path() helper for that formatting instead of keeping
separate local copies in GRANT, REMOVE and REVOKE.

No behavior change.
This commit is contained in:
Mario Fetka
2026-05-29 12:33:32 +02:00
parent f3e77819d8
commit 34ec41e760
5 changed files with 36 additions and 47 deletions

21
grant.c
View File

@@ -25,6 +25,7 @@
#include "net.h"
#include "ncpapi.h"
#include "trustee.h"
#define GRANT_BINDERY_USER 0x0001
#define GRANT_BINDERY_GROUP 0x0002
@@ -100,20 +101,6 @@ static void grant_usage_after_error(void)
grant_usage_ex(0, 1, 2);
}
static void grant_header_path(char *out, char *path, int max)
{
char *p;
tool_header_path(out, path, max);
/* Novell GRANT displays server and volume as SERVER/SYS: while
* RIGHTS uses SERVER\SYS:. Keep the rest of the path with DOS
* backslashes. */
p = strchr(out, '\\');
if (p && strchr(out, ':') && p < strchr(out, ':'))
*p = '/';
}
static void grant_rights_bracket(uint16 rights, char *out)
{
/* Novell displays Supervisor as the full effective right mask. */
@@ -420,7 +407,7 @@ int func_grant(int argc, char *argv[], int mode)
if (!object_id) {
char header[300];
grant_header_path(header, path, sizeof(header));
trustee_header_path(header, path, sizeof(header));
fprintf(stdout, "\n%s\n", header);
if (objtype == GRANT_BINDERY_GROUP)
fprintf(stdout, "\aGroup \"%s\" not found.\n", objname);
@@ -437,7 +424,7 @@ int func_grant(int argc, char *argv[], int mode)
if (rc) {
char header[300];
grant_header_path(header, path, sizeof(header));
trustee_header_path(header, path, sizeof(header));
fprintf(stdout, "\n%s\n", header);
fprintf(stdout, "Invalid path or no match for pattern specified.\n\n");
return(grant_last_rc ? grant_last_rc : 1);
@@ -448,7 +435,7 @@ int func_grant(int argc, char *argv[], int mode)
char base[80];
char bracket[10];
grant_header_path(header, path, sizeof(header));
trustee_header_path(header, path, sizeof(header));
tool_basename(base, path, sizeof(base));
grant_rights_bracket(rights, bracket);