Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9291191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:35:26+00:00 2026-06-18T20:35:26+00:00

Couldn’t understand how the command line option below is used in practice. -T[level=1] I

  • 0

Couldn’t understand how the command line option below is used in practice.

-T[level=1]

I tried this code:

#commandoptionstest.rb
puts "hello world"

with various SAFE levels:

Output is OK

@ubuntu:~/script$ ruby -x commandoptionstest.rb
# => hello world

Why the error? What do I need to do in commandoptionstest.rb to allow -x with -T?

@ubuntu:~/script$ ruby -x -T commandoptionstest.rb
# => ruby: no -x allowed in tainted mode (SecurityError)

Output is coming

@ubuntu:~/script$ ruby -T commandoptionstest.rb
# => hello world

Output is coming

@ubuntu:~/script$ ruby -T1 commandoptionstest.rb
# => hello world

Output is coming

@ubuntu:~/script$ ruby -T2 commandoptionstest.rb
# => hello world

Output is coming

@ubuntu:~/script$ ruby -T3 commandoptionstest.rb
# => hello world

Again why the error?

@ubuntu:~/script$ ruby -T4 commandoptionstest.rb
# => commandoptionstest.rb:15:in `write': Insecure operation `write' at level 4 (SecurityError)
#   from commandoptionstest.rb:15:in `puts'
#   from commandoptionstest.rb:15:in `puts'
#   from commandoptionstest.rb:15:in `<main>'

With the help of the above code, could you please explain why the SAFE levels 1, 2, 3 are printing "hello world", while SAFE level 4 not? To allow the write operations at SAFE level 4, what should be done here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T20:35:28+00:00Added an answer on June 18, 2026 at 8:35 pm

    It sets the $SAFE level.

    This dictates how inputs are handled, along with a great number of other things regarding environment variables, I/O, threads, exceptions, interpreter command line args, etc.

    http://www.ruby-doc.org/docs/ProgrammingRuby/html/taint.html

    IMO the docs are a good place to start. If you have a question about a specific behavior, ask.


    To address your comment and your edits:

    Yes, I can, but the docs can too, and likely better.

    Why does -x not work?

    Because the docs say it won’t:

    $SAFE >= 1
       * The command-line options -e, -i, -I, -r, -s, -S, and -x are not allowed.

    [~]$ ruby –help
    Usage: ruby [switches] [–] [programfile] [arguments]
    # elided
    -T[level=1] turn on tainting checks

    So the default level if -T is specified with no number is 1, which means $SAFE >= 1, which means exactly what the docs say: -x is not allowed.

    Why doesn’t puts work?

    Difficult to say since you don’t actually provide the code you’re executing, but most likely, again, as the docs say:

    $SAFE >= 4
       * Can’t write to files or pipes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Couldn't find anything relevant in forums So ,Please help me with this code .I'm
couldn't find this on SO. I ran the following command in the terminal: >>
Couldn't register com.yourcompany.accessgalary with the bootstrap server. Error: unknown error code. This generally means
Couldn't comment on this post, which states the problem I'm experiencing: jQuery remove() on
I couldn't find anything similar to this anywhere. I have an array of pointers
I couldn't find this in the documentation. If I have a complex object in
I couldn't find anything on this, but probably its just because I don't know
I couldn't find a suitable title for this. I'm going to express my query
Couldn't find an answer to this anywhere, but essentially I am wanting to add
Couldn't seem to get any bites on this over at AskDifferent so thought I'd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.