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

  • Home
  • SEARCH
  • 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 9014417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:30:08+00:00 2026-06-16T03:30:08+00:00

I have a post-receive hook that call a bash script of mine (which will

  • 0

I have a post-receive hook that call a bash script of mine (which will pull the local repo and restart the Java server).

Here’s the owner info of the post-receive hook :

-rwsr-x--x 1 cyril devs   676 19 dec.  14:45 post-receive

As you can see, I set the setuid bit on this script in order to be run as cyril/devs also for other users.

The content of this script is rather simple :

echo "Running post-receive hook"
echo "Server will be up and running in about 1 minute"
/home/project/start_dev restart &

My script start_dev has those rights :

-rwsr-x---  1 cyril devs 1515 19 dec.  14:41 start_dev

Note: also the setuid.

If I push something to the server with the account cyril, it works perfectly.

If someone else, with an other account, push to the server, they got :

remote: /home/project/start_dev: line 52: kill: (11490) - Operation not allowed

(The kill is used to stop the instance.)

Why they have this errors, the script should be run as cyril, not the user, thus they should have the right to kill this instance, right?

What am I doing wrong?

  • 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-16T03:30:09+00:00Added an answer on June 16, 2026 at 3:30 am

    Apparently most Linux distributions disable setuid for shell scripts because of the massive security holes it can cause. More info here and from the setuid Wikipedia page.

    While the setuid feature is very useful in many cases, its improper use can pose a security
    risk if the setuid attribute is assigned to executable programs that are not carefully
    designed. Due to potential security issues, many operating systems ignore the setuid
    attribute when applied to executable shell scripts.

    One possible solution from the Tuxation page is to do the following:

    #include <stdio.h>
    #include <stdlib.h>
    #include <sys/types.h>
    #include <unistd.h>
    
    int main()
    {
       setuid( 0 );
       system( "/path/to/script.sh" );
    
       return 0;
    }
    

    Then setuid the resulting C program and use that as your hook. There’s also this commentary after that on the Tuxation page though:

    With all that said, running shell scripts with setuid isn’t very safe, and the distro
    designers had a pretty good idea of what they were doing when many of them disabled it.

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

Sidebar

Related Questions

I have one post-receive hook which will take one minute to execute. While executing
I have a git post receive hook that will trigger a build on my
I have the following post-receive hook I wrote on a virtual server such that
I have a post-commit hook in svn that runs fine from the command line
I have a test script to receive an xml file via http post and
I'm trying to set up a git post-receive hook such that when a commit
I have a post-hook function that receives some data for itself, reference to another
In the remote server I have a post-receive hook set up in order to
I found a post-receive hook for Git after some googling that I use to
I have facebook apps with flask with nginx and uwsgi. When it receive POST

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.