diff --git a/grant.c b/grant.c index cb36ea2..df87237 100644 --- a/grant.c +++ b/grant.c @@ -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); diff --git a/remove.c b/remove.c index 2d6d22f..18ad7dc 100644 --- a/remove.c +++ b/remove.c @@ -49,20 +49,6 @@ static void remove_usage_after_error(void) fprintf(stdout, "\n"); } -static void remove_header_path(char *out, char *path, int max) -{ - char *p; - - tool_header_path(out, path, max); - - /* Novell REMOVE 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 int remove_one(char *path, uint16 dhandle, uint32 object_id, uint16 objtype, char *objname, int forced_is_file) { @@ -97,7 +83,7 @@ static int remove_one(char *path, uint16 dhandle, uint32 object_id, { char header[300]; - remove_header_path(header, path, sizeof(header)); + trustee_header_path(header, path, sizeof(header)); fprintf(stdout, "%s\n", header); } diff --git a/revoke.c b/revoke.c index 34511a1..1e35b13 100644 --- a/revoke.c +++ b/revoke.c @@ -71,20 +71,6 @@ static void revoke_usage_full(int leading_blank, int bell_before_tail) fprintf(stdout, "* Use abbreviations listed above, separated by spaces.\n"); } -static void revoke_header_path(char *out, char *path, int max) -{ - char *p; - - tool_header_path(out, path, max); - - /* Novell REVOKE 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 int revoke_one(char *path, uint16 dhandle, uint32 object_id, uint16 revoke_mask, int forced_is_file) { @@ -140,7 +126,7 @@ static int revoke_one(char *path, uint16 dhandle, uint32 object_id, { char header[300]; char bracket[10]; - revoke_header_path(header, path, sizeof(header)); + trustee_header_path(header, path, sizeof(header)); trustee_rights_bracket(new_rights, bracket); fprintf(stdout, "%s\n", header); fprintf(stdout, "Trustee's access rights set to [%s]\r\n\n", bracket); diff --git a/trustee.c b/trustee.c index 2327c7b..cbf6d36 100644 --- a/trustee.c +++ b/trustee.c @@ -31,6 +31,35 @@ #define S_IFDIR 0040000 #endif + +/* + * trustee_header_path + * + * Purpose: + * Formats the path header used by GRANT, REMOVE and REVOKE. + * + * Parameters: + * out - destination buffer. + * path - source path to format. + * max - destination buffer size. + * + * Notes: + * Novell trustee tools display the server and volume separator as + * SERVER/SYS: while tools such as RIGHTS keep SERVER\SYS:. Keep all + * remaining path separators as DOS backslashes. + */ +void trustee_header_path(char *out, char *path, int max) +{ + char *p; + char *colon; + + tool_header_path(out, path, max); + + p = strchr(out, '\\'); + colon = strchr(out, ':'); + if (p && colon && p < colon) + *p = '/'; +} /* * trustee_parse_right_word * diff --git a/trustee.h b/trustee.h index 20147f5..f2ba9c9 100644 --- a/trustee.h +++ b/trustee.h @@ -45,6 +45,7 @@ int trustee_parse_right_word(char *s, uint16 *rights); void trustee_rights_bracket(uint16 rights, char *out); +void trustee_header_path(char *out, char *path, int max); uint32 trustee_lookup_object(char *name, uint16 *objtype, int objtype_given); int trustee_path_is_dir(char *path);