2 Unix SMB/Netbios implementation.
4 Samba utility functions
5 Copyright (C) Andrew Tridgell 1992-2000
6 Copyright (C) Luke Kenneth Casson Leighton 1996-2000
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 * this module stores a user_struct which can be globally accessed (by root)
25 * across process boundaries, in order to obtain info about users currently
28 * the database key is the process number (pid) of the creater of the
29 * structure plus the vuid - SMB virtual user id. NORMALLY, this would
30 * be smbd pid and an smbd-generated vuid.
36 extern int DEBUGLEVEL
;
38 static TDB_CONTEXT
*tdb
= NULL
;
40 BOOL
tdb_delete_vuid( const vuser_key
*uk
)
53 DEBUG(10,("delete user %x,%x\n", uk
->pid
, uk
->vuid
));
55 prs_init(&key
, 0, 4, False
);
56 if (!vuid_io_key("key", &k
, &key
, 0))
61 prs_tdb_delete(tdb
, &key
);
68 BOOL
tdb_lookup_vuid( const vuser_key
*uk
, user_struct
**usr
)
76 (*usr
) = (user_struct
*)malloc(sizeof(**usr
));
92 DEBUG(10,("lookup user %x,%x\n", uk
->pid
, uk
->vuid
));
94 prs_init(&key
, 0, 4, False
);
95 if (!vuid_io_key("key", &k
, &key
, 0))
102 prs_tdb_fetch(tdb
, &key
, &data
);
106 if (!vuid_io_user_struct("usr", (*usr
), &data
, 100))
109 prs_free_data(&data
);
116 prs_free_data(&data
);
121 BOOL
tdb_store_vuid( const vuser_key
*uk
, user_struct
*usr
)
135 DEBUG(10,("storing user %x,%x\n", uk
->pid
, uk
->vuid
));
137 prs_init(&key
, 0, 4, False
);
138 prs_init(&data
, 0, 4, False
);
140 if (!vuid_io_key("key", &k
, &key
, 0) ||
141 !vuid_io_user_struct("usr", usr
, &data
, 100) ||
142 prs_tdb_store(tdb
, TDB_REPLACE
, &key
, &data
) != 0)
145 prs_free_data(&data
);
150 prs_free_data(&data
);
154 BOOL
vuid_init_db(void)
156 tdb
= tdb_open(lock_path("vuid.tdb"), 0, 0, O_RDWR
| O_CREAT
, 0600);
160 DEBUG(0,("vuid_init_db: failed\n"));
164 DEBUG(10,("vuid_init_db: opened\n"));