Logging problem with Edit Active Domain

p5yk0tik
2009-09-22
2013-01-23
  • p5yk0tik

    p5yk0tik - 2009-09-22

    Hello Everyone,

    I have recently had a problem with one of our Admin users accidentally clicking on the "YES" link in the domain list, and disabling a mail domain. This created an infinite loop of E-Mail, which took 1.5 hours to resolve back to the PostFixAdmin page, where the mistake was finally noticed.

    We did not pick up on this any earlier, because there was no logging of this event against the domain in Postfix Admin.

    However, if I modify an Alias on that domain, that action makes an entry into the PostfixAdmin log database in MySQL, so it is easy to see when this happened, and where from.

    So I attempted to add logging for the domain, copying some code from other places where PostfixAdmin creates log entries - unfortunately none of these changes have worked at all.

    The one I expected most to work was the line:

    db_log ($SESSID_USERNAME, $fDomain, 'edit_domain_state', $fDomain);

    which was added to edit-active-domain.php in several locations in attempt to make it work.

    However, it does not work. No errors are output in the log files or sql log table, so this is a problem to troubleshoot.

    Has anyone managed to add logging against the edit active domain activity in PostfixAdmin? Or have an idea how this might be done?

    It is not required for the domain list page, as I have removed the Active Status (YES/NO) links, this only displays YES/NO now, without a link. I do require it for the domain edit page, where one can untick/tick the "Active" box for the domain.

    Please help :)

     
  • p5yk0tik

    p5yk0tik - 2009-09-22

    I have managed to part-way solve this issue!

    I changed the code in edit-domain.php. Starting at line 92, the file used to read:


    if ($fActive == "on") {<br>
    $sqlActive = db_get_boolean(True);<br>
    }<br>
    else {<br>
    $sqlActive = db_get_boolean(False);<br>
    }<br>


    I have added a db_log line to the code, and this has created log file entries in the log table of the SQL database. They are not completely tidy, for example the edit_domain_state log code is not recognised and needed to be added to functions.inc.php - which is done, but this still will not display in the logs. Anyway, we have enough information with the new code to tell Who, Where, and When the Active/Inactive switch is set on the domain.
    Here's the new piece of code:<br>


    if ($fActive == "on") {<br>
    $sqlActive = db_get_boolean(True);<br>
    db_log ($SESSID_USERNAME, $domain, "edit_domain_state", "DOMAIN ENABLED");<br>
    }<br>
    else {<br>
    $sqlActive = db_get_boolean(False);<br>
    db_log ($SESSID_USERNAME, $domain, "edit_domain_state", "DOMAIN DISABLED");<br>
    }


    I hope this helps someone, it certainly made my brain cook for a while. Would be really nice if we could have this functionality enabled by default, or selectable in configuration, as yet it remains unsupported.

    I will post more information if I get this tidied up a bit. As it serves the purpose the tidy up has been back-burnered :)

    Have fun. Anyone with new ideas/help is welcome to comment! (Especially if they have a cleaner way to do this).

    Cheers,
    Mike

     
  • p5yk0tik

    p5yk0tik - 2009-09-22

    Yuck. I just realised that when I was editing, my <BR> tags were performing line breaks, but now the message is posted my line breaks have gone and the damn BR tags are back. Sorry if the code doesn't make sense any more, it did before this stupid Forum mangled my code. Sorry, I dont have time to repost it.

     
  • Christian Boltz

    Christian Boltz - 2009-10-25

    Good catch. I opened a bugreport about the missing domain logging so that this won't get lost.

     

Log in to post a comment.