Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

scripting help with errors

  • 16-04-2004 5:47pm
    #1
    Banned (with Prison Access) Posts: 13,018 ✭✭✭✭


    first of all using redhat 9 php and apache

    right have this script and i want to call it from php so that it will let certain ipaddress/macadress access the net via iptables

    can do this staticly but want to do it dynamicly which means when a users logs on the script will be call and the mac address will be inserted into the iptable and will open the net for a user (the users will be wireless clients)

    anyway have 4 scripts that will do the job but a number of errors remain
    i had a premature header error but got rid of it by entering a echo content-type/plain
    echo at the top of each script

    but now im getting the following error from the error log in the apache folder

    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] Password:
    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] Password:
    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] /root/user/www/cgi-bin/change: line 9: /root/user/apache/logs/users.txt: No such file or directory
    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] Password:
    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] Password:
    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] /root/user/www/cgi-bin/add: line 9:
    : command not found
    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] Password:
    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] /root/user/www/cgi-bin/change: line 12:
    : command not found
    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] /root/user/www/cgi-bin/change: line 13:
    : command not found
    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] /root/user/www/cgi-bin/change: line 14:

    the file users.txt does exist in that folder!!

    and what the hell is up with those password errors!?
    i have no references to passwords or nothing

    ight as well post up the script as well

    [PHP]#!/bin/bash
    #
    echo Content-type: text/plain
    echo
    read ip_address
    IPTABLES=/sbin/iptables

    sudo arp > /root/users/apache/logs/users.txt

    sudo awk '{if ($1 == "'"$ip_address"'") print $3}'
    /root/users/apache/logs/users.txt |
    /root/users/www/cgi-bin/add
    sudo $IPTABLES -t nat -A POSTROUTING -s $ip_address -j MASQUERADE[/PHP]

    the others are more or less the same and i get the password errors from them too and a nice error on a line where there is no text (typical!)
    if i can debug one script ill be able to do the rest no problem at all

    when i run the above script from a treminal i get
    Content-type: text/plain and the i freezes on me


Comments

  • Registered Users, Registered Users 2 Posts: 1,862 ✭✭✭flamegrill


    Originally posted by jank
    first of all using redhat 9 php and apache

    right have this script and i want to call it from php so that it will let certain ipaddress/macadress access the net via iptables

    can do this staticly but want to do it dynamicly which means when a users logs on the script will be call and the mac address will be inserted into the iptable and will open the net for a user (the users will be wireless clients)

    anyway have 4 scripts that will do the job but a number of errors remain
    i had a premature header error but got rid of it by entering a echo content-type/plain
    echo at the top of each script

    but now im getting the following error from the error log in the apache folder

    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] Password:
    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] Password:
    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] /root/user/www/cgi-bin/change: line 9: /root/user/apache/logs/users.txt: No such file or directory
    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] Password:
    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] Password:
    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] /root/user/www/cgi-bin/add: line 9:
    : command not found
    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] Password:
    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] /root/user/www/cgi-bin/change: line 12:
    : command not found
    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] /root/user/www/cgi-bin/change: line 13:
    : command not found
    [Fri Apr 16 19:28:57 2004] [error] [client 192.168.1.49] /root/user/www/cgi-bin/change: line 14:

    the file users.txt does exist in that folder!!

    and what the hell is up with those password errors!?
    i have no references to passwords or nothing

    ight as well post up the script as well

    [PHP]#!/bin/bash
    #
    echo Content-type: text/plain
    echo
    read ip_address
    IPTABLES=/sbin/iptables

    sudo arp > /root/users/apache/logs/users.txt

    sudo awk '{if ($1 == "'"$ip_address"'") print $3}'
    /root/users/apache/logs/users.txt |
    /root/users/www/cgi-bin/add
    sudo $IPTABLES -t nat -A POSTROUTING -s $ip_address -j MASQUERADE[/PHP]

    the others are more or less the same and i get the password errors from them too and a nice error on a line where there is no text (typical!)
    if i can debug one script ill be able to do the rest no problem at all

    when i run the above script from a treminal i get
    Content-type: text/plain and the i freezes on me


    The use of sudo will prompt for a password.

    Best thing for this sort of thing is pop the details into a db and cron a script run by root every minute to add it or run the daemon as root.

    Paul


  • Registered Users, Registered Users 2 Posts: 1,862 ✭✭✭flamegrill


    or if a cron job isn't quick enough?

    a shell script doing the following:

    while (true) do
    /path/to/some/file/to/run/every/10/seconds.sh
    sleep 10
    done

    simply set the sleep option to what ever you want.

    Paul


  • Banned (with Prison Access) Posts: 13,018 ✭✭✭✭jank


    wouldnt it be easier to just set the no password option in the sudoers file

    root ALL=(ALL) NOPASSWD: ALL

    would that work!?
    does the scripts have to be owned by root for this to work


  • Closed Accounts Posts: 97 ✭✭rde


    root ALL=(ALL) NOPASSWD: ALL
    I get a nosebleed every time I read someone, somewhere suggesting this; anything that'll allow sudo su - should be avoided like several plagues. By all means use sudo, but set up a User_Alias and a Cmnd_Alias instead. The syntax is a trifle arcane if you're not used to it, but it's nothing a quick man visudo shouldn't sort out.


Advertisement