SUMMARY: using getprpwent(3) with C2?

From: Simon Greaves <greaves_s_at_usp.ac.fj>
Date: Mon, 22 Jun 1998 17:05:34 +1200

In essence, my original query was 'how do I get the getprpw* calls to
work?' and the answer is 'by reading the manual pages properly!'. I'm a
little embarrassed to say that though I did read the manual page several
times I somehow managed to miss the bit that says:
 
  Programs must call set_auth_parameters() before any other action in
main().

Seems glaringly obvious now, must have been the thought of an nice cold
beer after all this sun... :-)

Thanks to:

        Jon Morgan <jmorgan_at_dircon.co.UK>
        MC.Vialatte_at_cust.univ-bpclermont.FR
        Lucien_HERCAUD_at_paribas.COM
        Jane Kramer <Jane.Kramer_at_oberlin.EDU>
        Eric <Eric.Rostetter_at_utoledo.EDU>
        Randy Rodgers <rrodgers_at_ci.ft-wayne.in.US>
        Don Newcomer <newcomer_at_dickinson.EDU>
        Steve VanDevender <stevev_at_hexadecimal.uoregon.EDU>

I'll append Jon's response as it sums up pretty well what everyone else
said.

Incidentally - in the interim I started coding up a program in perl,
capturing the output from 'edauth -g' instead of using getprpw*. This is
nicer in some respects because the names of the ttys are not truncated
as they are in the pr_field C structure.
 
> Hi Simon,
>
> You need to initialise the database first. This is quite simple
> and can be done as follows (code amended to include the
> initialisation command that you need to enter):
>
> #include <sys/types.h>
> #include <sys/security.h>
> #include <prot.h>
>
> void
> main(void)
> {
> struct pr_passwd *prPasswd;
>
> /* Initilise access to the database... */
>
> set_auth_parameters(argc, argv) ;
>
> /* Rewind the authorisation database... */
>
> setprpwent()
>
> /* try getting an entry by name.. */
> prPasswd = getprpwnam("greaves");
> }
>
> From the man page for setprpwent(3):
>
> Programs must call set_auth_parameters() before any other action
> in main().
>
> Hope this helps!
>
> -jon.

Simon
--
Simon Greaves                           voice: (+679) 212114
Computer Centre                         fax:   (+679) 304089
The University of the South Pacific     email: greaves_s_at_usp.ac.fj
Suva, Fiji

attached mail follows:



This report relates to a message you sent with the following header fields:

  Message-id: <358D890A.D177F3D7_at_usp.ac.fj>
  Date: Mon, 22 Jun 1998 10:28:26 +1200
  From: Simon Greaves <greaves_s_at_usp.ac.fj>
  To: alpha-osf-manager_at_ornl.GOV
  Subject: SUMMARY: using getprpwent(3) with C2?

Your message cannot be delivered to the following recipients:

  Recipient address: alpha-osf-manager_at_ornl.GOV
  Reason: Remote SMTP server has rejected address
  Diagnostic code: smtp; 550 5.1.1 unknown or illegal user: alpha-osf-manager_at_ornl.GOV
  Remote system: dns; oaunx2.ctd.ornl.gov (TCP|144.120.8.4|2332|128.219.128.94|25) (oaunx2.ctd.ornl.gov -- Server ESMTP [PMDF V5.1-10 #23475]) (oaunx2.ctd.ornl.gov)


attached mail follows:



In essence, my original query was 'how do I get the getprpw* calls to
work?' and the answer is 'by reading the manual pages properly!'. I'm a
little embarrassed to say that though I did read the manual page several
times I somehow managed to miss the bit that says:

  Programs must call set_auth_parameters() before any other action in
main().

Seems glaringly obvious now, must have been the thought of an nice cold
beer after all this sun... :-)

Thanks to:

        Jon Morgan <jmorgan_at_dircon.co.UK>
        MC.Vialatte_at_cust.univ-bpclermont.FR
        Lucien_HERCAUD_at_paribas.COM
        Jane Kramer <Jane.Kramer_at_oberlin.EDU>
        Eric <Eric.Rostetter_at_utoledo.EDU>
        Randy Rodgers <rrodgers_at_ci.ft-wayne.in.US>
        Don Newcomer <newcomer_at_dickinson.EDU>
        Steve VanDevender <stevev_at_hexadecimal.uoregon.EDU>

I'll append Jon's response as it sums up pretty well what everyone else
said.

> Hi Simon,
>
> You need to initialise the database first. This is quite simple
> and can be done as follows (code amended to include the
> initialisation command that you need to enter):
>
> #include <sys/types.h>
> #include <sys/security.h>
> #include <prot.h>
>
> void
> main(void)
> {
> struct pr_passwd *prPasswd;
>
> /* Initilise access to the database... */
>
> set_auth_parameters(argc, argv) ;
>
> /* Rewind the authorisation database... */
>
> setprpwent()
>
> /* try getting an entry by name.. */
> prPasswd = getprpwnam("greaves");
> }
>
> From the man page for setprpwent(3):
>
> Programs must call set_auth_parameters() before any other action
> in main().
>
> Hope this helps!
>
> -jon.


Simon
-- 
Simon Greaves				voice: (+679) 212114
Computer Centre				fax:   (+679) 304089
The University of the South Pacific	email: greaves_s_at_usp.ac.fj
Suva, Fiji
Received on Mon Jun 22 1998 - 07:08:32 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:38 NZDT