CGI script

Following is SE linux policy definition.
When permitting access to CGI scripts in system's '\tmp' directory,
which entries should be made in place of (A) and (B)

    policy_module(apache_ext, 1.0.1)

    require {
        type httpd_sys_script_t;
        type(A);
    }

    allow httpd_sys_script_t(B) :file_r_file_p
Chetan TamboliStudentAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dfkeCommented:
Hi,

it looks like that policy came from audit2allow.

So it might look something like:
require {
        type httpd_sys_content_t;
        type httpd_sys_script_t;
        class dir add_name;
        class file { write create };
}

#============= httpd_sys_script_t ==============
allow httpd_sys_script_t httpd_sys_content_t:dir add_name;
allow httpd_sys_script_t httpd_sys_content_t:file { write create };

Open in new window


Except for a couple of problems, the biggest being that all CGI Scripts would be able to read write all Apache content and you probably don't want that. The policy is also fragile since you might get an AVC like httpd_sys_script_t is not allowed to append to httpd_sys_content_t.

Better would be:
manage_files_pattern(httpd_sys_script_t, httpd_sys_content_t, httpd_sys_content_t) 

Open in new window

So what's a better label that can be used? You can use httpd_sys_rw_content_t for the /tmp directory.
# semanage fcontext -a -t httpd_sys_rw_content_t "/tmp(/.*?)"
# restorecon -R -v /tmp

Open in new window

Cheers
2

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dfkeCommented:
My comment has all the info to help out solving this question.

Cheers
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.