readonly user for cgis

Dietmar Ruzicka dr at cubit.at
Wed Aug 6 18:01:53 CEST 2003


Hi,

we need readonly users for the webinterface. readonly means the user
(contact) should only see his hosts and services, but should not be able
to execute any commands except creating comments.

It did a very dirty quick patch to the current 1-x-cvs version. If the
contact name ends with "_ro" (for readonly) the contact is not able to
execute any commands except creating new comments. 

It think a good solution would be a configuration option in the cgi.cfg
like 

Format: readonly_user=<user1>,<user2>,<user3>,...<usern> 
Example: readonly_user=bob,alice


Bye 

Dietmar



cube1:/usr/local/src/nagios-1-x-cvs# diff -c
/home/druzicka/nagios-all/cvs/123/nagios/cgi/cmd.c cgi/cmd.c
*** /home/druzicka/nagios-all/cvs/123/nagios/cgi/cmd.c  Fri May 30
21:25:55 2003
--- cgi/cmd.c   Wed Aug  6 17:23:53 2003
***************
*** 556,562 ****
        time_t t;
        char buffer[MAX_INPUT_BUFFER];
        contact *temp_contact;
!
   
        /* get default name to use for comment author */
        temp_contact=find_contact(current_authdata.username,NULL);
--- 556,562 ----
        time_t t;
        char buffer[MAX_INPUT_BUFFER];
        contact *temp_contact;
!       char *substr;
   
        /* get default name to use for comment author */
        temp_contact=find_contact(current_authdata.username,NULL);
***************
*** 565,570 ****
--- 565,585 ----
        else
                comment_author=current_authdata.username;
   
+
+       if ((substr=strstr(comment_author,"_ro"))!=NULL) {
+           if (!strcmp(substr,"_ro")) {
+             printf("<P><DIV ALIGN=CENTER CLASS='cmdType'>You, %s are
requesting to ",comment_author);
+             switch(cmd){
+             case CMD_ADD_HOST_COMMENT:
+             case CMD_ADD_SVC_COMMENT:
+               printf("add a %s
comment",(cmd==CMD_ADD_HOST_COMMENT)?"host":"service");
+               break;
+             default:
+               printf("execute an command. This is not allowed! Sorry
you are a readonly user!</DIV>");
+             return;
+             } //case
+           } //if strcmp
+         } // if strstr
   
        printf("<P><DIV ALIGN=CENTER CLASS='cmdType'>You are requesting
to ");
   
cube1:/usr/local/src/nagios-1-x-cvs#




-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01




More information about the Developers mailing list