Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Usage of su -m / rc.subr _user support

    Scheduled Pinned Locked Moved Development
    5 Posts 2 Posters 524 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      scottster
      last edited by

      Anybody know why "Bad -c option" is triggered below? Is this an environment/shell configuration difference triggered by the usage of -m?

      From the shell in 2.4.4-RELEASE:
      su -m nobody -c 'sh -c "echo foo"'
      Bad -c option

      From a stock 11.2 FreeBSD install:
      su -m nobody -c 'sh -c "echo foo"'
      foo

      /etc/rc.subr supports providing the _user option, to allow daemons to be run as a different user, and this same error is triggered when attempting to use this.

      1 Reply Last reply Reply Quote 0
      • jimpJ
        jimp Rebel Alliance Developer Netgate
        last edited by

        I tried it on several boxes with several different shells, and it worked for me each time. On 2.4.4, 2.5.0 snapshots, and FreeBSD 12.

        Remember: Upvote with the ๐Ÿ‘ button for any user/post you find to be helpful, informative, or deserving of recognition!

        Need help fast? Netgate Global Support!

        Do not Chat/PM for help!

        1 Reply Last reply Reply Quote 0
        • S
          scottster
          last edited by scottster

          Jim, it looks like the difference may be specific to connecting to the console using "admin" instead of "root". Connecting and issuing the prior steps as root works fine, whereas admin does not (for me).

          Admin has SHELL=/etc/rc.initial, whereas root has SHELL=/bin/sh, I haven't looked further at whether this explains the difference.

          This (rc.subr) also worked while logged in as user admin:
          _doit="echo $_doit | su -m $_user -c 'sh -s'"

          1 Reply Last reply Reply Quote 0
          • jimpJ
            jimp Rebel Alliance Developer Netgate
            last edited by

            That would probably explain it, since admin is setup different.

            You could also install the sudo package and use that, which is less likely to care about such things.

            Remember: Upvote with the ๐Ÿ‘ button for any user/post you find to be helpful, informative, or deserving of recognition!

            Need help fast? Netgate Global Support!

            Do not Chat/PM for help!

            S 1 Reply Last reply Reply Quote 0
            • S
              scottster @jimp
              last edited by

              This change appears to make it consistent, if you wanted it to be:
              rc.initial:
              /bin/sh -c $1
              change to
              /bin/sh -c "$1"

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.