Re: C functions, arguments, and ssh oh my! - Mailing list pgsql-general

From Peter Eisentraut
Subject Re: C functions, arguments, and ssh oh my!
Date
Msg-id Pine.LNX.4.30.0103272154210.1215-100000@peter.localdomain
Whole thread Raw
In response to C functions, arguments, and ssh oh my!  (Joel Dudley <Joel.Dudley@DevelopOnline.com>)
List pgsql-general
Joel Dudley writes:

> PG_FUNCTION_INFO_V1(ssh_exec);
>
> Datum
> ssh_exec(PG_FUNCTION_ARGS)
> {
>         char sshcmd[255];
>
>         strncpy(sshcmd, "/usr/local/bin/plsshexec ", 255);
>         strncat(sshcmd, *uname, 255);
>         strncat(sshcmd, " ", 255);
>         strncat(sshcmd, *uid, 255);
>         strncat(sshcmd, " ", 255);
>         strncat(sshcmd, *gid, 255);
>         system(sshcmd);
>         return 0;
> }

You missed the part about fetching the arguments using PG_GETARG_xxx.
Also you should use PG_RETURN_xxx and you need to null-terminate your
string.

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/


pgsql-general by date:

Previous
From: Alfred Perlstein
Date:
Subject: Re: C functions, arguments, and ssh oh my!
Next
From: Tom Lane
Date:
Subject: Re: C functions, arguments, and ssh oh my!