Warn Before Executing Particular Command

I'm running CentOS 6.8 and use bash. I would like a warning to appear to the user who runs the command " service httpd restart "

E.g.

# service httpd restart
are you sure y/n
n
#
(or if y, the command executes).

I looked into it a little but am not sure of the best approach. Aliases I believe are only one word, maybe aliasing the existing 'service' to a script which checks for the 'httpd restart' arguments?

I read shell functions are preferred over aliases, could a shell function do this? I wasn't sure if the shell function went in .bashrc and also needed an alias to work?

I also read something about precmd() and preexec() functionality for bash, but wasn't sure if that would be required, or work, for this case?

Other possibility, modify /sbin/service or /etc/init.d/httpd?

Thanks for any info,

sg

---------- Post updated at 11:49 AM ---------- Previous update was at 08:23 AM ----------

I was able to use this:

while true; do
    read -p "Are you sure (y/n)?" yn
    case $yn in
        [Yy]* ) stop; start; break;;
        [Nn]* ) exit;;
        * ) echo "Please answer yes or no.";;
    esac
done

found here -- within the restart case statement in /etc/init.d/httpd, commenting the original stop / start commands -- it seems OK. I still appreciate any suggestion that is considered cleaner.

Thanks,
sg

Can anyone run that command on your machine? If true it is a terrible idea. On a reasonably well secured system, only privileged accounts can start and stop services.

I would put a group acl on the service command like maybe admin. Create one or two accounts in that group. Do not let anyone else into the group. Don't give away the password.

Alias-ing the command will not work if some user tries

/usr/bin/service httpd restart

Same with scripting. You should never make a script redirect for a command.
You will screw up booting the system. Especially if you have to answer a prompt to get it to run. The reboot will just hang.

Thanks for the helpful suggestions Jim!