Permalink
Browse files

""

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@691 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
klacke committed May 25, 2004
1 parent f0929a2 commit 6dc4cca7703156783b5af8f2431cbb387286baf4
Showing with 45 additions and 1 deletion.
  1. +15 −0 c_src/setuid_drv.c
  2. +8 −0 src/yaws.erl
  3. +22 −1 src/yaws_ctl.erl
View
@@ -15,6 +15,7 @@
#include <string.h>
#include <unistd.h>
#include <pwd.h>
+#include <stdlib.h>
#include "erl_driver.h"
@@ -52,6 +53,20 @@ static ErlDrvData setuid_start(ErlDrvPort port, char *buf)
}
endpwent();
return (ErlDrvData) -1;
+ case 'n': {
+ int uid = atoi(t);
+ while ((pe = getpwent())) {
+ if (pe->pw_uid == uid) {
+ sprintf(xbuf, "ok %s", pe->pw_name);
+ endpwent();
+ driver_output(port,xbuf, strlen(xbuf));
+ return (ErlDrvData) port;
+ }
+ }
+ endpwent();
+ driver_output(port, "ok -", 4);
+ return (ErlDrvData) port;
+ }
case 'g': /* getuid */
sprintf(xbuf, "ok %d", getuid());
driver_output(port,xbuf, strlen(xbuf));
View
@@ -1495,6 +1495,14 @@ user_to_home(User) ->
Home
end.
+uid_to_name(Uid) ->
+ erl_ddll:load_driver(filename:dirname(code:which(?MODULE)) ++
+ "/../priv/", "setuid_drv"),
+ P = open_port({spawn, "setuid_drv " ++ [$n|integer_to_list(Uid)]}, []),
+ receive
+ {P, {data, "ok " ++ Name}} ->
+ Name
+ end.
tmp_dir() ->
case os:type() of
View
@@ -22,7 +22,7 @@
%% assumes the appropriate file structures
%% are already created with the right perms
-start(GC, FirstTime) when FirstTime == false ->
+start(_GC, FirstTime) when FirstTime == false ->
ok;
start(GC, true) ->
case proc_lib:start_link(?MODULE, run, [GC]) of
@@ -336,6 +336,27 @@ s_cmd(Fd, SID, Term) ->
Res.
+ls() ->
+ case file:list_dir("/tmp/yaws") of
+ {ok, List} ->
+ lists:foreach(
+ fun(D) ->
+ ls(D)
+ end, List);
+ _ ->
+ ok
+ end.
+
+
+ls(Dir) ->
+ Ctl = ctl_file(Dir),
+ case file:read_file_info(Ctl) of
+ {ok, FI} ->
+ ok
+ end.
+
+
+
%% send a hup (kindof) to the yaws server to make it
%% reload its configuration and clear its caches

0 comments on commit 6dc4cca

Please sign in to comment.