Oracle DBA & All IT » Database, DBA, Oracle » ปิด Commands โดยใช้ Table: PRODUCT_USER_PROFILE #security
ปิด Commands โดยใช้ Table: PRODUCT_USER_PROFILE #security
ปิดคำสั่งโดยใช้ Table: PRODUCT_USER_PROFILE #security
table นี้จะช่วยให้เราปิดการใช้งานคำสั่งบางคำสั่งที่เราไม่ต้องการให้ user ใช้งานได้โดยง่าย เช่น command SPOOL or ALTER ,etc.
Script สำหรับ generate table PRODUCT_USER_PROFILE ให้สร้างภายใต้ owner SYSTEM
: $ORACLE_HOME\sqlplus\admin\pupbld.sql อยู่ภายใต้ owner SYSTEM
- DBAs สามารถปิดคำสั่งการใช้งานบน SQL and SQL*Plus ได้
- การจำกีดสิทธิ์จะมีผลเมื่อมีการ log on SQL*Plus ครั้งต่อไป
การปิดสิทธิ์คำสั่งบน SQL or SQL*Plus ทำได้โดยง่ายๆ เพียง insert ค่าลงใน table PRODUCT_USER_PROFILE โดยการกำหนด username สามารถทำเป็น wild card '%' ได้
– For example 'SC%' ซึ่งจะปิดการใช้งานคำสั่งของ username ทั้งหมดที่ขึ้นต้นด้วย 'SC'
For example:
CONNECT system/manager Connected. INSERT INTO product_user_profile (product, userid, attribute, char_value, date_value) VALUES('SQL*Plus', 'SCOTT', 'HOST', 'DISABLED', NULL); 1 row created. INSERT INTO product_user_profile (product, userid, attribute, char_value, date_value) VALUES('SQL*Plus', 'JHUNTER', 'SPOOL', 'DISABLED', NULL); 1 row created. COMMIT; Commit complete. SELECT product, userid, attribute, char_value FROM product_user_profile; PRODUCT USERID ATTRIBUTE CHAR_VALUE ------------ ---------- ------------ ------------ SQL*Plus SCOTT HOST DISABLED SQL*Plus JHUNTER SPOOL DISABLED |
จากตัวอย่างข้างบนถ้า SCOTT พยายามจะใช้ คำสั่ง HOST หรือ ถ้า JHUNTER พยายามจะใช้ SPOOL จะได้ Error ตามด้านล่าง
SQL> connect scott/tiger Connected. SQL> host ls SP2-0544: Command "host" disabled in Product User Profile SQL> !ls -l SP2-0544: Command "! (HOST)" disabled in Product User Profile -------------------------------------------------------------- SQL> connect jhunter/xxxxxx Connected. SQL> spool report.txt SP2-0544: Command "spool" disabled in Product User Profile |
การเปิดสิทธิ์ที่เราปิดไว้ ทำได้โดยการ delete row ที่เราใส่ไปใน table PRODUCT_USER_PROFILE ตามตัวอย่างด้านล่าง
CONNECT system/manager Connected. DELETE FROM product_user_profile WHERE product='SQL*Plus' AND userid='SCOTT' and attribute='HOST'; 1 row deleted. DELETE FROM product_user_profile WHERE product='SQL*Plus' AND userid='JHUNTER' and attribute='SPOOL'; 1 row deleted. COMMIT; Commit complete. |
ตารางอธิบายความหมายของ column ใน table
COLUMN |
DESCRIPTION |
---|---|
PRODUCT |
The name of the Oracle product, uses "SQL*Plus" as the only value. This table was designed for all types of products such as Forms and Reports, but only SQL*Plus stuck around. |
USERID |
The username you want to restrict. |
ATTRIBUTE |
The command you want to restrict, e.g. HOST. |
CHAR_VALUE |
Should contain the value DISABLED for the products that should be disabled for the user. |
ตารางด้านล่างแสดงคำสั่งที่เราสามารถที่จะปิดสิทธิ์ได้
SQL*PLUS COMMAND |
DESCRIPTION |
---|---|
COPY |
Disables the COPY command in SQL*Plus |
EDIT |
Disables the user from entering the edit command to edit a script or the current SQL |
EXECUTE |
Disables the execute command, i.e. execution of procedures, packages, pl/sql blocks, etc. |
EXIT |
The user is disallowed to enter EXIT command |
GET |
GET is used to get a script to the SQL*Plus environment but not execute it. This disallows that command. |
SQL*PLUS COMMAND |
DESCRIPTION |
HOST |
This command takes the user to the prompt of the host operating system, such as the shell in UNIX or the command prompt in Windows. Disabling this command also disables the shortcuts defined for that. For instance, the exclamation mark “!” is a shortcut for HOST in UNIX, and that is disabled too. |
PASSWORD |
This command is used by the user to change his or her own password without the ALTER USER command. |
QUIT |
Same as exit. |
RUN |
This disables running of an SQL script. This also disables the shortcuts '@" and "@@" used to run the scripts. |
SAVE |
This disallows saving the current SQL to a file. |
SET |
All SET commands as in SET PROMPT, SET ROLE, etc, are disabled. |
SPOOL |
Disallows saving the output to a file. |
START |
START is used to get an SQL script file and execute it. This disables that command. |
คำสั่ง SQL เพิ่มเติมที่สามารถปิดสิทธิ์ได้
ALTER |
ANALYZE |
AUDIT |
CONNECT |
CREATE |
DELETE |
DROP |
GRANT |
INSERT |
LOCK |
NOAUDIT |
RENAME |
REVOKE |
SELECT |
SET CONSTRAINTS |
SET ROLE |
SET TRANSACTION |
TRUNCATE |
UPDATE |
|
คำสั่งที่ใช้สำหรับ PL/SQL ก็สามารถปิดได้เช่นกัน
-
BEGIN – This disables a user from entering BEGIN as the first line of SQL*Plus. The user can enter EXECUTE to execute a pl/sql block, and it must be disabled separately.
-
DECLARE – This disallows the user from entering DECLARE as the first line of a statement. By disallowing BEGIN, DECLARE, and EXECUTE, the user can be disallowed from running any kind of Pl/SQL in a SQL*Plus environment.
Filed under: Database, DBA, Oracle · Tags: oracle, product_user_profile, security, sql, sql*plus