[SOLVED] Require authentication before my script executes

OK I got a little bash script where I type in how many minutes my computer will poweroff.
Normally, it can be ran with regular user even the code contains command "poweroff" which requires root privilegies so, when times up, instead of poweroff, I get message: "poweroff: must be superuser"
Now, I want it to be like, when I run it (./myscript) to require authentication before the script even start like, for example Gparted requires, so if an authentication passes, my scirpt can run and have permission to do whatever it's written in it (in this case, 'poweroff').
Thanks ^_^
Last edited by broi (2012-03-24 23:38:44)

(From another thread)
foppe wrote:
# Check for admin rights. If user is not an admin user, exit the script
if [ $UID != 0 ]
then
echo "You need to be root to run this script! Exiting..."
exit
fi
This snippet checks if you've sudo-ed it (or ran as root). All subsequent commands can be coded without sudo.

Similar Messages

  • Why is my hard drive requiring authentication before allowing me to drag documents to it?

    Why is my hard drive requiring authentication before allowing me to drag documents to it?

    Why do you even think it needs defraginng, your iMac is not an old MS Windows machine?. Defragging HD's is a very antiquated and unneccessary thing to do. Even current MS Windows machines don't need it.

  • How to validate required fields before executing menu item ("Save As") using cutom Javascript?

    Hi,
    Sorry, I am new to PDF Development. I tried creating PDF using Acrobat XI Pro. During creation, I have encountered issues in running custom JavaScript. The requirement is to validate all the required fields before saving the PDF. I tried using the following scripts to validate the said required fields. But, it's not working.
    Option 1: If the field is null, a message box will appear.
    if(this.getfield("textbox") = null){
    app.alert("required");
    else {app.execMenuItem("SaveAs");}
    Option 2: If the field is required, a message box will appear.
    var f = this.getField("textbox");
    f.required = true;
    if(f = true)
    app.alert('required');
    else
    app.execMenuItem("SaveAs");
    The scripts mentioned above are not working. I wanted to validate the required fields before saving the PDF.
    In addition, I tried validating each field using the following script:
    f = getField(event.target.name)
    if (f.value.length == 0)
        f.setFocus()
        //Optional Message - Comment out the next line to remove
        app.alert("This field is required. Please enter a value.")
    When I open the PDF, the script is working. However, when the message box pops out, the "OK" button is not working as expected. The message box is not closing. I tried opening the form in a site in different Java versions (like 7-11 and 7-67). It's working in version 7-67. I tried upgrading the Java version from 7-11 to 7-67. Still, it doesn't work.
    I would appreciate your feedback on this matter.

    If you set the fields as required, then when the user hits the print button you could run this script:
    var txt = form1.execValidate();
    if (txt == true){
    print command
    This code assumes that the root node of your form is form1. Also ensure you put a message into the Empty Message parameter for each field that you want to mark s required.

  • Any Way to Make an Action Require Authentication?

    Hi,
    Is there any way to make an Automator action require user authentication before running? Before some of my actions execute, I want the OSX authentication screen to pop up, the way it does during software installation, when the Mac wakes from sleep, when a user tries to change something in the System Preferences, and so on. I'd also like to make sure that before these particular Automator actions run, they accept authentication from a particular user only. That way, other users won't be able to copy the actions in question to their own accounts and run them after authenticating with their own passwords.
    Thanks in advance for any help,
    Skell

    If you get a dump of a script application such as:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #FFEE80;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    property PropertyString : "this is some testing text"
    set GlobalString to "this is a global text string"
    SomeHandler(GlobalString)
    log result
    on SomeHandler(SomeText)
    set HandlerString to "this is a local text string"
    if SomeText is not "PASSWORD" then
    return "FAIL"
    else
    return "OK"
    end if
    end SomeHandler
    </pre>
    ... at the beginning of the resource fork you can clearly see the text strings defined and their variable names. I don't particularly want to know enough about AppleScript tokens to tell what the specific code statements are, but in this example I can see enough to make some guesses about a password dialog.
    Since these kinds of things are still readable in a run-only script, if one isn't going to use something like a keychain and has to put in some kind of password test, care must be taken to obfuscate the related items so that a casual glance doesn't give things away. Dynamically building any check strings and dialog texts, not using obvious variable names, and scattering code across multiple handlers will make it harder to guess what the password is.

  • Does requiring authentication for external drives, via profiles, actually work?

    USB and Firewire drives still mount after applying a profile that requires authentication.  Use to work with MCXs.  Is this a known issue with ML?
    Cheers,
    Ernesto

    Bill-
    If all you are doing is managing 30 GB of pre-existing JPEGs in 2007 iVMP is probably superior. However I would venture a guess that you also intend to capture new images with your DSLR. For that you very much want Aperture. And IMO moving to 2008 and beyond Aperture's potential far exceeds iVMP's.
    And you did note that iVMP is now owned by MS; not good.
    Solving an entire workflow is not something easily done in a few forum paragraphs. I strongly recommend that every DSLR photog with adequate computer hardware first spend $33 and work through the tutorial CD Apple Pro Training Series: Aperture 1.5 (Apple Pro Training) by Orlando Luna and Ben Long (Paperback - Oct 18, 2006).
    Have the CD and a MacIntel with 2 GB or preferably more of RAM prior to ordering the Aperture trial so you don't waste time of the 30 day trial. Note that the value is in the tutorial, not in using the book as a manual. Due to the limited hard drive capacity, anyone with a laptop should focus on developing a "Reference Masters" workflow.
    You say JPEGs, no RAW. I would in the strongest possible terms recommend that you consider switching to a RAW workflow. In addition to allowing extraordinary post process editing, RAW image files contain much more image data. I believe that your DSLR will capture up to a dozen RAW pix before the buffer fills. Shooting JPEGs is a serious under utilization of a capable DSLR.
    -Allen Wicks

  • Web Services - This WSDL requires authentication credentials. Please supply

    I am trying to access a web service on our network. This is an open service and doesn't require you to log in. I can put the link into IE and the service homepage is shown however when I try to create a new service in APEX I get the error:
    This WSDL requires authentication credentials. Please supply the username and password below.
    I have tried entering my Windows Username and password (the web service is hosted on a windows VM on our network) however this didn't work.
    Anybody know what might be causing this?
    Thanks

    Hello,
    If you enter the name/location of that script in your browser, you'll see the contents (hopefully). Then you can see the name or IP address and port of your proxy. Try these ones first in the APEX setting.
    If that doesn't work, add your (windows) username/password also. The problem is (apart from the evident security issue) that you probably forced to change your windows password every now and then, and you'll forget to change that setting here. As far as I know you can't enter the URL to the script in the APEX proxy property - however...I never tried...
    Greetings,
    Roel
    http://roelhartman.blogspot.com/
    You can reward this reply by marking it as either Helpful or Correct ;-)

  • JavaMail: How to tell if SMTP server requires authentication

    I am writing an application that sends notification emails. I have a configuration screen for the user to specify the SMTP hostname and optionally a username and password, and I want to validate the settings. Here is the code I am using to do this:
    Properties props = new Properties();
    props.put("mail.transport.protocol", "smtp");
    if (mailUsername != null || mailPassword != null)
        props.put("mail.smtp.auth", "true");
    Session session = Session.getInstance(props, null);
    transport = session.getTransport();
    transport.connect(mailHostname, mailUsername, mailPassword);
    transport.close();This works if the user enters a username and password (whether they are valid or not), or if the username and password are empty but the SMTP server does not require authentication. However, if the server requires authentication and the username and password are empty, the call to transport.connect() succeeds, but the user will get an error later on when the app tries to actually send an email. I want to query the SMTP server to find out if authentication is required (not just supported), and inform the user when they are configuring the email settings. Is there any way to do this? I suppose I could try sending a test email to a dummy address, but I was hoping there would be a cleaner way.

    Thanks for your help. This is what I ended up doing, and it seems to work. For anyone else interested, after the code above (before transport.close(), I try to send an empty email, which causes JavaMail to throw an IOException, which I ignore. If some other MessagingException occurs, then there is some other problem (authentication required, invalid from address, etc).
    try
       // ...code from above...
       // Try sending an empty  message, which should fail with an
       // IOException if all other settings are correct.
       MimeMessage msg = new MimeMessage(session);
       if (mailFromAddress != null)
           msg.setFrom(new InternetAddress(mailFromAddress));
       msg.saveChanges();
       transport.sendMessage(msg,
           new InternetAddress[] {new InternetAddress("[email protected]")});
    catch (MessagingException e)
        // IOException is expected, anything else (including subclasses
        // of IOException like UnknownHostException) is an error.
        if (!e.getNextException().getClass().equals(IOException.class))
            // Handle other exceptions
    }Edited by: svattom on Jan 7, 2009 7:37 PM
    Edited by: svattom on Jan 7, 2009 10:01 PM
    Changed handling of subclasses of IOException like UnknownHostException

  • Problem while executing procedure thru Shell script (EXECUTE IMMEDIATE)

    Hi All,
    I have created a procedure where i am passing column name, tablename and business date. The procedure gets last 5 business date excluding Saturday and sunday based on business date.
    i am using EXECUTE IMMEDIATE statement in the procedure, where i am replacing the column name, table name, and business date & then executing this statement.
    stmt := 'select count(1) FROM '||tblname||' where trunc('||date_column||')= :1';
    EXECUTE IMMEDIATE l_stmt into tbl_count using to_char(in_date, 'DD-MON-YYYY') ;
    It will give me the count of all 5 days for a particular dates. When i run the procedure in SQL*Plus/TOAD, it gives me desired result. When i run this in UNIX shell script, it runs fine but at end gives following error:
    SP-xxx: Bind varaible not declared.
    Can someone tell me where might be the problem?

    Hello, if you could put a {noformat}{noformat} before and after your snippets of code please, it makes it much easier to decipher.
    You have:EXECUTE IMMEDIATE l_stmt into tbl_count using to_char(in_date, 'DD-MON-YYYY') ;
    Where it should be:EXECUTE IMMEDIATE l_stmt into tbl_count using TRUNC(in_date) ;
    Additionally, you do not need the SQL script, you could simply have:sqlplus -S $ORA_UID/$ORA_PWD@$DSQuery <<EOF >>${TMP_DIR}/report.log 2>&1
    whenever sqlerror exit failure
    whenever oserror exit failure
    set serveroutput on;
    set pages 0;
    set feed off;
    exec return_date ('20090515','STIFAPACDTR','ASOFD','n');
    print;
    quit
    EOF
    if [[ $? -ne 0 ]]
    then
    echo "sqlplus did not run successfully,verify"
    echo "For errors please check ${TMP_DIR}/report.log file\n Exiting..."
    else
    echo "$0 script executed successfully"
    fi
    exit $?
    You don't need any of this:if /usr/xpg4/bin/grep -e 'ORA-' -e '^ERROR at' -e 'unknown command' ${TMP_DIR}/report.log
    then
    print "sqlplus did not run successfully,verify"
    print "For errors please check ${TMP_DIR}/report.log file\n Exiting..."
    exit 1
    fi
    if [http:// -s ${TMP_DIR}/report.log ]
    then
    print "`echo $0 script executed successfully"
    grep -v '^$'${TMP_DIR}/report.log > ${TMP_DIR}/report.csv
    else
    print "${TMP_DIR}/report.log file not generated, verify, \n exiting"
    exit 1
    fi
    outFLAG="n"
    done
    I'm not sure that that will fix your problem here, but can you try again with those changes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Want to fire event receiver before workflow is execute while adding File in Document Library.

    Hi,
    I have Event receiver and workflow attached to same Document
    Library.
    Is it possible to fire event receiver before Workflow is
    executed ?
    Regards,
    Milind

    Hi,
    According to your description, my understanding is that you want fire event receiver before workflow is excuted.
    If the workflow for a list is set to auto-start, it will always execute before event receiver by default.
    Here is a similar thread for your reference:
    http://sharepoint.stackexchange.com/questions/3147/execution-order-of-event-receivers-and-workflow-on-a-list
    As a workaround, you can set the workflow start by manually. Then , after executing the event receiver, you can start workflow using code at the end of event receiver.
    Here is a demo for your reference:
    http://zimmergren.net/technical/starting-a-sharepoint-workflow-from-code-event-receiver
    More information about start workflow using C#:
    http://jainnitin2411.wordpress.com/2012/07/06/programmaticallystartsharepointworkflow/
    Best regards,
    Zhengyu Guo
    Zhengyu Guo
    TechNet Community Support

  • I'm trying to log into my site that requires authentication but I get a popup that says it doesn't require authentication and then I get a 403

    I have a site that requires authentication. In the past i have logged in using firefox with the following format
    http://username:password@sitename:siteport/specificsiteurlinfo
    and gotten in just fine. I just set up a new computer with a new instance of firefox and try the same thing but I now get the following popup-
    "You are about to log in to the site "sitename" with the username "username", but the website does not require authentication. This may be an attempt to trick you.
    Is "sitename" the site you want to visit?"
    When I click "yes" Firefox appears to try to go to the site without any authentication and I of course get a 403 Forbidden error.
    I have tried reverting back to old versions of Firefox with no luck.
    Any advice would be greatly appreciated.
    Thank you.

    The purpose of that warning is to alert you to the possibility of being fooled by a link with login credentials at the beginning. On your old computer you might have tweaked this setting to limit when the warning appears:
    http://kb.mozillazine.org/Network.http.phishy-userpass-length
    This article discusses the steps to adjust that setting to fit your needs: [http://fix.lazyjeff.com/2011/04/disable-firefox-login-prompt.html].

  • Require Fields Before Printing

    I've been looking through the documentation of Adobe Live Cycle Designer and cannot find my answer. I have two fields, which I would like to be required. Upon a user pressing the print button, if these fields are empty, require it before the form will print.
    I have looked everywhere and can't find my answer. I'm assuming the form will still print if the fields are blank if the user were to use the File>Print option through their specified browser?
    Any help would be appreciated.

    i found a super cool secret code to validate the whole form in one line of code!
    F.execValidate();
    so my print button is a normal button (not a print button)
    with this code for onclick:
    if(F.execValidate())
    xfa.host.print(1, "0", (xfa.host.numPages - 1).toString(), 0, 1, 0, 0, 0);
    easy as that!
    IMPORTANT:
    - unfortunatly it does not check if required fields are empty
    - it only checks the "validation pattern" under Object > Value
    - the "Error" box beside "validation pattern message" MUST be checked (if it is not checked, your validation errors will still popup, but the function will return true when it should be false - and therefore the print box will popup)

  • Firefox required Authentication when enter in reporting services, only in firefox and safari

    Hi SSRS required authentication when enter in Firefox an safari, work fine in IE, GOOGLE AND OPERA
    this link not work, firefox required credentials:
    https://support.mozilla.org/en-US/kb/Firefox%20asks%20for%20user%20name%20and%20password%20on%20internal%20sites
    I want only configure in server, not in client side.

    I have done this configuration for safari:
    http://stackoverflow.com/questions/22108080/cant-connect-to-ssrs-in-php
    If you are using default values, you can copy the minimum element structure:
    <AuthenticationTypes>
    <RSWindowsBasic/>
    </AuthenticationTypes>
    But this required credentials in other browsers and when reset the server throw error.

  • Server requires authentication - How do I program for this?

    Hello,
    I'm testing out a webpage I have created that will be used to send email. I have DSL service...just recently subscribed. Previously I had Dial up. The server at that time didn't require authentication, but now that I have DSL it does. I'm a bit lost as to how to update my program (I've included the snippet in the post), so that it will run correctly. I am having some difficulty.
    My program looked like this :
    String POP3 = "pop.windstream.net";
    String SMTP = "smtp.windstream.net";
    // Specify the SMTP host
    Properties props = new Properties();                                           
    props.put(POP3, SMTP);
    // Create a mail session
    Session ssn = Session.getInstance(props, null);
    ssn.setDebug(true);                  
    //...html to make up the body of the message
    // set the from information
    InternetAddress from = new InternetAddress(emailaddress, fromName);
    // Set the to information
    InternetAddress to = new InternetAddress(EmailAddress2, toName);
    // Create the message
    Message msg = new MimeMessage(ssn);
    msg.setFrom(from);
    msg.addRecipient(Message.RecipientType.TO, to);
    msg.setSubject(emailsubject);
    msg.setContent(body, "text/html");                      
    Transport.send(msg);     
    //....                        I did some research already, and have looked at some other forum posts. The one thing I have noted when I run my program is that the dos prompt for tomcat is showing this:
    *DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smpt,com.sun.mail.smtp.SMTPTransport,Sun Microsystem, Inc]*
    DEBUG SMTP: useEhlo true, useAuth false
    DEBUG: SMTPTransport trying to connect to hose "localhost", port 25
    My ISP provider, Windstream, assures me that port 25 is NOT blocked. Also, I've noticed that useAuth is set to false, whereas the posts I have been looking at say true. It would make sense to me for it to be set to true in my case, since my server requires authentication. But how do I do that?
    I found this bit of information from another person's post :
    props.setProperty("mail.smtp.auth", "true");
    you also need an Authenticator like this
    Authenticator auth = new Authenticator() {
    private PasswordAuthentication pwdAuth = new PasswordAuthentication("myaccount", "mypassword");
    protected PasswordAuthentication getPasswordAuthentication() {
    pwdAuth;
    Session session = Session.getDefaultInstance(props, auth);*
    Post located at http://forums.sun.com/thread.jspa?forumID=43&threadID=537461
    From the FAQ section of JavaMail
    Q: When I try to send a message I get an error like SMTPSendFailedException: 530, Address requires authentication.
    A: You need to authenticate to your SMTP server. The package javadocs for the com.sun.mail.smtp package describe several methods to do this. The easiest is often to replace the call Transport.send(msg); with
    String protocol = "smtp";
    props.put("mail." + protocol + ".auth", "true");
    Transport t = session.getTransport(protocol);
    try {
    t.connect(username, password);
    t.sendMessage(msg, msg.getAllRecipients());
    } finally {
    t.close();
    You'll have to supply the appropriate username and password needed by your mail server. Note that you can change the protocol to "smtps" to make a secure connection over SSL.
    One thing I have noticed in the majority of the posts is that useAuth in the tomcat dos prompt should be set to true, and not false. Mine is coming up as false. Also, I think it should be set to true because the ISP's server requires authentication for sending and receiving email.
    Can you please provide me with some input on how to update my program so it will run?
    Thank you in advance:)

    Thank you for replying.
    Per your advice, I made these changes to my code:
    Properties props = new Properties();                                           
    props.setProperty("mail.smtp.auth", "true");               
    props.put("mail.pop3.host", POP3);
    props.put("mail.smtp.host", SMTP);
    Session ssn = Session.getInstance(props, null); The props.setProperty("mail.smtp.auth","true"); is something I found previously to posting my question. I'm assuming this is the line of code that has changed useAuth from false to true...is that correct?
    I'm most pleased to report that with the changes made above, my program works! But is my code good? As soon as I start taking on clients, I will need my code to be reliable, and it needs to work with Dial Up and DSL connections.
    With regards to your question about how I had found the authentication code but hadn't used it. Well, I did try it, again, this was previous to posting my question, and the compiler couldn't compile the program because of this statement - pwdAuth;
    I also tried this code I had found in the JavaMail FAQ section -
    String protocol = "smtp";
    props.put("mail." + protocol + ".auth", "true");
    Transport t = session.getTransport(protocol);
    try {
    t.connect(username, password);
    t.sendMessage(msg, msg.getAllRecipients());
    } finally {
    t.close();
    }But according to the compiler, t.connect(username,password); was not an available method. I checked the documentation and found that to be true. Do you have any suggestions? Looking into the documentation I find that there are 3 methods called connect that are inherited by the Transport class from javax.mail.Service.
    connect()
    connect(java.lang.String host, int port, java.lang.String user, java.lang.String password)
    connect(java.lang.String host, java.lang.String user, java.lang.String password)
    I would opt to try the third connect method, but what would I put for host?
    Thank you for helping me with this issue, I'm not an expert on using the JavaMail package, at least not yet, and I appreciate the help you have provided.

  • Accessing a WMS created with Geoserver that requires authentication

    Can I create a WMS theme in Map Viewer that is served from Geoserver? This Geoserver WMS requires authentication. I can access it in ArcGIS but I don't know how to access it in Map Viewer.

    Where is the Authentication?  The following operates are done in 11.1.1.7.1. Is there any problem? Please talk more detail!
    1.Create a WMS theme by Using the Map Builder tool. It's name is wms_theme130wps. The result is the following:
    Record contents to be stored into USER_SDO_THEMES
    NAME: wms_theme130wps
    DESCRIPTON:
    BASE_TABLE: WMS
    GEOMETRY_COLUMN: WMS
    STYLING_RULES:
    <?xml version="1.0" standalone="yes"?>
    <styling_rules theme_type="wms">
      <service_url> http://localhost:8080/mapviewer/wms? </service_url>
      <user> wms </user>
      <password> +wE1RbfVl94yXdaLJKtG09v64OPJtG40 </password>
      <layers> COUNTIES_TERR </layers>
      <version> 1.3.0 </version>
      <srs> EPSG:4326 </srs>
      <format> image/png </format>
      <bgcolor> 0xA6CAF0 </bgcolor>
      <transparent> true </transparent>
      <exceptions> xml </exceptions>
    <capabilities_url> http://localhost:8080/mapviewer/wms? </capabilities_url>
      </styling_rules>
    2. Request with the URL, http://localhost:8080/mapviewer/wms?REQUEST=GetMap&VERSION=1.3.0&LAYERS=wms_theme130wps&WIDTH=1500&HEIGHT=560&CRS=SDO:8307&BBOX=-180,-90,180,90&FORMAT=image/png.
    This request is without any Authentication message!
    3.Request returns a PNG Image.

  • Accessing a page requiring authentication

    Hello,
    I am working on a project to get some information from a web page.
    I am using the following piece of code to access and get the info from the page:
    URL url = new URL(<PAGE ADDRESS>);
    URLConnection conn = url.openConnection();
    BufferedReader in = new BufferedReader(new InputStreamReader
    (conn.getInputStream()));
    String inputLine;
    while ((inputLine = in.readLine()) != null)
    in.close();
    This code was working fine.
    However, now I have to access a page that requires authentication. And when I use the code above the error code 401 is returned.
    Somebody knows how I can access a page that requires authentication?
    How can I pass the needed user name and password to connect to the page?
    Thanks,
    Leandro

    Basically you set an HTTP header with the authentication credentials, which as I recall are encoded but not encrypted. IIRC the header is "Authorization". IIRC you set the header with java.net.URLConnection.addRequestProperty or .setRequestProperty.
    http://www.faqs.org/rfcs/rfc2616.html
    http://www.faqs.org/rfcs/rfc2617.html

Maybe you are looking for

  • Newbie cfc question

    I have an index.cfm with a login form which uses the security.cfc below There are two cffunctions. The first one "authenticate" works fine which checks the passed username and password from the login form and returns the result to the index.cfm page

  • Best Possible match

    Hello All, I got a table called TAC_CODE_MASTER and TAC_CODE is one of its field. TAC_CODE is 8 characters long and it can hold upto 8 charaters If i were to find a data such as 'A2345678' and if this does not exist then I should get the most possibl

  • Displaying JTable using GridBagLayout

    Hii Javaties I am displaying all my GUI using GridBagLayout Manager. But i dont know , how to add a JTable using GridBagLayout manager. I[b] want tht each column of the JTable be displayed in each cell . i.e column 1 should be displayed at position 1

  • Req additional fields in MB51

    hi friends.. In tcode MB51, we have customer number (kunnr) and vendor number (lifnr) but my client asking me for customer name and vendor name along with customer and vendor number.. Is it possible to add this field in standard tcode MB51? Is any ex

  • Looking for CURSOR replacement, please suggest!

    Hello Experts, I having some master tables "#ACTION_MASTER" & "#RPT_MILE_MASTER" and a link table "#ACTION_MILE_RPT_LINK" showing their relationship. And again I having a derive table "#TBL" to finally update the master table ''#ACTION_MASTER". I am