![스크립트를 통해 바이너리를 실행할 때 권한 혼란](https://linux55.com/image/114437/%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EB%A5%BC%20%ED%86%B5%ED%95%B4%20%EB%B0%94%EC%9D%B4%EB%84%88%EB%A6%AC%EB%A5%BC%20%EC%8B%A4%ED%96%89%ED%95%A0%20%EB%95%8C%20%EA%B6%8C%ED%95%9C%20%ED%98%BC%EB%9E%80.png)
ls -al /home/dmsinst1/sqllib/adm/db2start
-r-sr-sr-x 1 root dmsiadm1 93613 Jun 26 14:14 /home/dmsinst1/sqllib/adm/db2start
ls -al /home/bpminst1/sqllib/adm/db2start
-r-sr-sr-x 1 root bpmiadm1 93613 Jun 26 14:15 /home/bpminst1/sqllib/adm/db2start
groups dmsinst1
dmsinst1 : dmsiadm1
groups bpminst1
bpminst1 : bpmiadm1
따라서 다음 스크립트를 루트로 실행할 때:
#!/bin/bash
su bpminst1 -c "/home/bpminst1/sqllib/adm/db2start"
su dmsinst1 -c "/home/dmsinst1/sqllib/adm/db2start"
나는 얻다:
[root@dmsnl857-vm ~]# ./startAll.sh
SQL1092N The requested command or operation failed because the user ID does not have the authority to perform the requested command or operation. User ID: "BPMINST1".
06/29/2017 09:16:03 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.
두 번째 명령은 분명히 오류 없이 실행됩니다.
고쳐 쓰다: 그리고set -x
[root@dmsnl857-vm ~]# ./startAll.sh
+ echo 'Starting BPM DB2 instance ... '
Starting BPM DB2 instance ...
+ su bpminst1 -c /home/bpminst1/sqllib/adm/db2start
SQL1092N The requested command or operation failed because the user ID does not have the authority to perform the requested command or operation. User ID: "BPMINST1".
+ echo 'Starting DMS DB2 instance ... '
Starting DMS DB2 instance ...
+ su dmsinst1 -c /home/dmsinst1/sqllib/adm/db2start
06/29/2017 09:44:13 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.