Granting privileges doesn't work - plsql

I have created package with couple of procedures, which are working perfectly, when I access package using my own username and password (package owner's).
To access my package from another user ora17, I granted privileges:
grant execute on package_name TO ora17;
then from ora17 user I ran following:
CREATE SYNONYM package_name FOR LOGIN.package_name;
following teacher's instructions.
Trying to access my program from browser, f.e. using url: https://somehost/pls/st12/package_name.customers
I am getting following error:
Thu, 28 Dec 2017 15:12:19 GMT
Failed to parse target procedure
package_name.customers: PROCEDURE DOESN'T EXIST
What am I doing wrong here?
UPD:
executing
describe package_name;
it gives me error:
ORA-04043: object "LOGIN"."PACKAGE_NAME" does not exist

Solution for this was simple, I just should have put owner's username instead of LOGIN here:
CREATE SYNONYM package_name FOR LOGIN.package_name;

Related

Regarding to the R and Github

I tried to create Github repository through entering the following command in the R console:
devtools::use_github("https://github.com/SimonFans/RP")
But it gives such kind of error:
Error in gh::gh("POST /user/repos", name = pkg$Package, description = gsub("\n", :
GitHub API error (401): 401 Unauthorized
Bad credentials
Does anyone knows how to solve that?
If you execute this command, a new GitHub repo will be created via the GitHub API, therefore you must provide a GitHub
personal access token (PAT) via the argument auth_token, which defaults to the value of the
GITHUB_PAT environment variable. Obtain a PAT from https://github.com/settings/tokens.
The "repo" scope is required which is one of the default scopes for a new PAT.
You don't have this variable set therefore you need to specify it explicitly in your call to function use_github.

Rmysql connection failing

The sysadmin just made SSL connection compulsory and since then I'm not able to access the mysql db anymore from R (even if I'm able to access it through Workbench) using the package RMysql. I tried multiple options without success and here is the error I get in R Studio:
Error in .local(drv, ...) :
Failed to connect to database: Error: Access denied for user 'blabla'#'host.blablabla' (using password: YES)
I read that I should modify my cnf file, but as I could not find it I created one in the /etc folder and still did not work. Should I save it somewhere else? Am I missing something?
Solved using the RMySql version that is on GitHub at the moment.

Grant UTL_HTTP permission in PLSQL

I would like to get HTML content from a certain webpage in my function. I read I can do it with the UTL_HTML package in PLSQL. So I made the following code in the project:
v_webcontent := utl_http.request(v_weblink);
Here the v_webconent and v_weblink are declared earlier. running this in de function gives an PLSQL exception: PLS-00201: identifier 'UTL_HTTP' must be declaredI guess this problem is because the package isn't available (from this link: same error message).
I followed the advice. So I created a new database connection in sql developer as the SYSTEM role (SYS didn't work, it sayd I could only logon using SYSDBA or SYSOPER but both wouldn't take the standard password I created with the database). Then I entered the code in the link above.
GRANT EXECUTE ON SYS.UTL_HTTP TO [database];
The user I created is named 'Database'. It first gave me an error without the [] square brackets. Table or view does not exist so I then put the brackets around it. Now it gives error:
Error starting at line : 1 in command -
GRANT EXECUTE ON SYS.UTL_HTTP TO [database]
Error report -
SQL Error: ORA-00987: missing or invalid username(s)
00987. 00000 - "missing or invalid username(s)"
*Cause:
*Action:
So I have no idea how to fix this. In the link above OP said that he got an other error, so I also checked if I didn't have the same problem. I entered:
SELECT * FROM dba_objects WHERE object_name='UTL_HTTP'
It returned 4 entry's. With owners: SYS, SYS, PUBLIC and APEX_040000.
Can somebody help me? Do I need to logon as SYS and with what passwords?
Since 11g you also have to create an access control list ('ACL') which specifies which users have access to particular domains, it is no longer sufficient to just grant users execute privileges on utl_http!
Something like this should work in 11g(after granting execute privileges on UTL_HTTP to your database user, as specified by the accepted answer) :
SQL> BEGIN
2 DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(acl=>'mikesacl.xml',
3 description=>'access control list example',
4 principal=>'HR',
5 is_grant=>TRUE,
6 privilege=>'connect');
7 commit;
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> begin
2 DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(
3 acl=>'mikesacl.xml',host=>'*');
4 commit;
5 end;
6 /
PL/SQL procedure successfully completed.
Here is a very helpful link which explains the parameters of the above two functions :
http://www.oracleflash.com/36/Oracle-11g-Access-Control-List-for-External-Network-Services.html
Good luck!
Log on as SYS AS SYSDBA.
Execute grant execute on sys.utl_http to "Database"; Do not use any square brackets!
That should work.
Piece of advice: Do not name your DB user 'Database'.
To reset your SYS password
Run cmd.exe as administrator.
cd to your ${ORACLE_HOME}/database.
Find the PWDsomething.ora file there (where something will be your instance name), copy its name (into clipboard).
Run orapwd file=PWDsomething.ora password=SomePasswordOfMine force=y, where PWDsomething.ora will be replaced with the file name from the step 3 and SomePasswordOfMine must be replaced by whatever password you wish to have.
That might work.

Rmpi, OpenCPU, and Apparmor: DENIED request for "/"

I have an R package that sends out a job to the OpenMPI cluster I have running by means of the Rmpi package. All works as expected within an R session run from the console. However, when I try to execute the relevant function with from my OpenCPU server like this (details changed to protect the innocent):
curl -XPOST http://99.999.999.99/ocpu/library/MyPackage/R/my_cluster_function
I get this error:
R call failed: process died.
(Other, non-cluster calling functions within the package work as expected via OpenCPU). I noticed in /var/log/kern.log a variety of requests being DENIED by apparmor, and I have been able to resolve most of them by adding entries into /etc/apparmor.d/opencpu.d/custom to allow OpenMPI to access the files it needs. However, I cannot resolve these two issues (again, IP address changed) related to "open" requests for location "/":
Oct 26 03:49:58 99.999.999.99 kernel: [142952.551234] type=1400 audit(1414295398.849:957): apparmor="DENIED" operation="open" profile="opencpu-main" name="/" pid=22486 comm="orted" requested_mask="r" denied_mask="r" fsuid=33 ouid=0
Oct 26 03:49:58 99.999.999.99 kernel: [142952.556422] type=1400 audit(1414295398.857:958): apparmor="DENIED" operation="open" profile="opencpu-main" name="/" pid=22485 comm="apache2" requested_mask="r" denied_mask="r" fsuid=33 ouid=0
Adding this to my apparmor rules did not help:
/* r,
Two questions:
Why is opencpu trying to read from my root level directory (or does this mean something else)?
More urgently, how can I resolve this apparmor issue?
Thanks.
You might need to add both apparmor rules
/ r,
/* r,
The first rule allows directory listing of / and the second rule allows read access to any file under /.
I don't understand why Rmpi wants to read / or why were you getting process died error instead of access denied. Are you sure the problem is completely resolved?

Using sqldf & RPostgrSQL in opencpu app

I'm creating a very simple sqldf app where I want to query postgresql database and return results. Here is my R code:
getproperties <- function(name="") {
options(sqldf.RPostgreSQL.user ="user",
sqldf.RPostgreSQL.password ="password",
sqldf.RPostgreSQL.dbname ="db",
sqldf.RPostgreSQL.host ="server",
sqldf.RPostgreSQL.port =5432,
sqldf.driver = "PostgreSQL")
property <- sqldf("select name, url from aston_hotels.property")
return(property)
}
When I call this using OpenCpu
curl http://localhost/ocpu/user/kesav/library/mylib/getproperties/json --data name=kk
I get the following error
R call failed: process died.
Don't know what's I'm doing wrong. Can anyone point me to an example on how to use DBI from OpenCpu?
Thanks in advance
If the function works when running it on the same machine the terminal but not within OpenCPU, it is likely a security problem. Please check in /var/log/kern.log if there are any lines printed containing DENIED when using the application.
If this is the case, you can add the appropriate privileges the the security profile by editing
/etc/apparmor.d/opencpu.d/custom
Also see the server manual section titled Customizing the security profile on this topic.

Resources