9 static char *period(long sec);
11 static char *devtypes[] = {
12 "beep", "cd", "cdfs", "datalink", "dfs", "disk", "diskfs", "fs", "inport",
13 "kbd", "mailslot", "midi-in", "midi-out", "mouse", "unc", "named-pipe", "net", "net",
14 "browser", "netfs", "null", "lpt", "nic", "lpr", "scanner", "eia-mouse",
15 "eia", "screen", "sound", "streams", "tape", "tapefs", "transport", "unknown",
16 "video", "virt-disk", "wav-in", "wav-out", "8042", "battery", "bus-exp", "modem", "vdm"
23 return (double)n / (1024.0 * 1024.0 * 1024.0);
34 for(sp = Shares; sp < &Shares[Nshares]; sp++){
35 fmtprint(f, "%-24q ", sp->name);
37 if(T2fsdeviceinfo(Sess, sp, &type, nil) != -1)
38 fmtprint(f, "%-16s ", devtypes[type]);
40 if(T2fssizeinfo(Sess, sp, &total, &unused) != -1)
41 fmtprint(f, "%6.1f/%-6.1f ", togb(total-unused), togb(total));
43 if(RAPshareinfo(Sess, sp, sp->name, &si2) != -1){
44 fmtprint(f, "%5d/%-5d %s", si2.activeusrs, si2.maxusrs, si2.comment);
63 if((got = RAPFileenum2(Sess, &Ipc, "", "", &fi)) == -1){
64 fmtprint(f, "RAPfileenum: %r\n");
68 for(i = 0; i < got; i++){
69 fmtprint(f, "%c%c%c %-4d %-24q %q ",
70 (fi[i].perms & 1)? 'r': '-',
71 (fi[i].perms & 2)? 'w': '-',
72 (fi[i].perms & 4)? 'c': '-',
73 fi[i].locks, fi[i].user, fi[i].path);
89 static Tab captab[] = {
95 { 0x20, "rpc-remote-APIs" },
97 { 0x80, "l2-oplocks" },
98 { 0x100, "lock-read" },
101 { 0x2000, "info-passthru" },
102 { 0x4000, "large-readx" },
103 { 0x8000, "large-writex" },
104 { 0x800000, "Unix" },
105 { 0x20000000, "bulk-transfer" },
106 { 0x40000000, "compressed" },
107 { 0x80000000, "extended-security" },
109 static Tab sectab[] = {
111 { 2, "challange-response" },
112 { 4, "signing-available" },
113 { 8, "signing-required" },
116 fmtprint(f, "%q %q %q %q %+ldsec %dmtu %s\n",
117 Sess->auth->user, Sess->cname,
118 Sess->auth->windom, Sess->remos,
119 Sess->slip, Sess->mtu, Sess->isguest? "as guest": "");
121 fmtprint(f, "caps: ");
122 for(i = 0; i < nelem(captab); i++)
123 if(Sess->caps & captab[i].val)
124 fmtprint(f, "%s ", captab[i].name);
127 fmtprint(f, "security: ");
128 for(i = 0; i < nelem(sectab); i++)
129 if(Sess->secmode & sectab[i].val)
130 fmtprint(f, "%s ", sectab[i].name);
134 fmtprint(f, "transport: cifs over netbios\n");
136 fmtprint(f, "transport: cifs\n");
147 if((got = RAPsessionenum(Sess, &Ipc, &si)) == -1){
148 fmtprint(f, "RAPsessionenum: %r\n");
152 for(i = 0; i < got; i++){
153 fmtprint(f, "%-24q %-24q ", si[i].user, si[i].wrkstn);
154 fmtprint(f, "%12s ", period(si[i].sesstime));
155 fmtprint(f, "%12s\n", period(si[i].idletime));
164 * We request the domain referral for "" which gives the
165 * list of all the trusted domains in the clients forest, and
166 * other trusted forests.
168 * We then sumbit each of these names in turn which gives the
169 * names of the domain controllers for that domain.
171 * We get a DNS domain name for each domain controller as well as a
172 * netbios name. I THINK I am correct in saying that a name
173 * containing a dot ('.') must be a DNS name, as the NetBios
174 * name munging cannot encode one. Thus names which contain no
175 * dots must be netbios names.
179 dfsredir(Fmt *f, char *path, int depth)
181 Refer *re, retab[128];
184 n = T2getdfsreferral(Sess, &Ipc, path, &flags, &used, retab, nelem(retab));
187 for(re = retab; re < retab+n; re++){
188 if(strcmp(path, re->path) != 0)
189 dfsredir(f, re->path, depth+1);
191 fmtprint(f, "%-32q %q\n", re->path, re->addr);
214 if((got = RAPuserenum2(Sess, &Ipc, &nl)) == -1)
215 if((got = RAPuserenum(Sess, &Ipc, &nl)) == -1){
216 fmtprint(f, "RAPuserenum: %r\n");
220 for(i = 0; i < got; i++){
221 fmtprint(f, "%-24q ", nl[i].name);
223 if(RAPuserinfo(Sess, &Ipc, nl[i].name, &ui) != -1){
224 fmtprint(f, "%-48q %q", ui.fullname, ui.comment);
228 free(ui.user_comment);
240 int got1, got2, i, j;
241 Namelist *grps, *usrs;
244 if((got1 = RAPgroupenum(Sess, &Ipc, &grps)) == -1){
245 fmtprint(f, "RAPgroupenum: %r\n");
249 for(i = 0; i < got1; i++){
250 fmtprint(f, "%q ", grps[i].name);
252 if((got2 = RAPgroupusers(Sess, &Ipc, grps[i].name, &usrs)) != -1){
253 for(j = 0; j < got2; j++){
254 fmtprint(f, "%q ", usrs[j].name);
267 nodelist(Fmt *f, int type)
271 static char *types[] = {
281 [9] "printer server",
282 [10] "dial-up server",
288 [16] "potential browser",
289 [17] "backup browser",
297 [25] "Terminal server",
304 if((got = RAPServerenum2(Sess, &Ipc, Sess->auth->windom, type, &more,
306 fmtprint(f, "RAPServerenum2: %r\n");
310 if((got = RAPServerenum3(Sess, &Ipc, Sess->auth->windom, type,
312 fmtprint(f, "RAPServerenum3: %r\n");
316 for(i = 0; i < got; i++){
317 fmtprint(f, "%-16q %-16q ", si[i].name, si[i].comment);
318 if(type != LIST_DOMAINS_ONLY){
319 fmtprint(f, "v%d.%d ", si[i].major, si[i].minor);
320 for(j = 0; j < nelem(types); j++)
321 if(si[i].type & (1 << j) && types[j])
322 fmtprint(f, "%s,", types[j]);
335 return nodelist(f, LIST_DOMAINS_ONLY);
339 workstationinfo(Fmt *f)
341 return nodelist(f, ALL_LEARNT_IN_DOMAIN);
348 static char when[32];
350 days = sec / (60L * 60L * 24L);
351 sec -= days * (60L * 60L * 24L);
352 hrs = sec / (60L * 60L);
353 sec -= hrs * (60L * 60L);
357 snprint(when, sizeof(when), "%d,%d:%d:%ld ", days, hrs, min, sec);
359 snprint(when, sizeof(when), "%d:%d:%ld ", hrs, min, sec);