9 static char *period(long sec);
19 if((n = RAPshareenum(Sess, &Ipc, &sip)) < 1){
20 fmtprint(f, "can't enumerate shares: %r\n");
24 for(i = 0; i < n; i++){
25 fmtprint(f, "%-13q ", sip[i].name);
28 for(j = 0; j < Nshares; j++)
29 if(strcmp(Shares[j].name, sip[i].name) == 0){
36 if(RAPshareinfo(Sess, sp, sp->name, &si2) != -1){
38 case STYPE_DISKTREE: type = "disk"; break;
39 case STYPE_PRINTQ: type = "printq"; break;
40 case STYPE_DEVICE: type = "device"; break;
41 case STYPE_IPC: type = "ipc"; break;
42 case STYPE_SPECIAL: type = "special"; break;
43 case STYPE_TEMP: type = "temp"; break;
44 default: type = "unknown"; break;
47 fmtprint(f, "%-8s %5d/%-5d %s", type,
48 si2.activeusrs, si2.maxusrs, si2.comment);
68 if((got = RAPFileenum2(Sess, &Ipc, "", "", &fi)) == -1){
69 fmtprint(f, "RAPfileenum: %r\n");
73 for(i = 0; i < got; i++){
74 fmtprint(f, "%c%c%c %-4d %-24q %q ",
75 (fi[i].perms & 1)? 'r': '-',
76 (fi[i].perms & 2)? 'w': '-',
77 (fi[i].perms & 4)? 'c': '-',
78 fi[i].locks, fi[i].user, fi[i].path);
94 static Tab captab[] = {
100 { 0x20, "rpc-remote-APIs" },
101 { 0x40, "status32" },
102 { 0x80, "l2-oplocks" },
103 { 0x100, "lock-read" },
104 { 0x200, "NT-find" },
106 { 0x2000, "info-passthru" },
107 { 0x4000, "large-readx" },
108 { 0x8000, "large-writex" },
109 { 0x800000, "Unix" },
110 { 0x20000000, "bulk-transfer" },
111 { 0x40000000, "compressed" },
112 { 0x80000000, "extended-security" },
114 static Tab sectab[] = {
116 { 2, "challange-response" },
117 { 4, "signing-available" },
118 { 8, "signing-required" },
121 fmtprint(f, "%q %q %q %q %+ldsec %dmtu %s\n",
122 Sess->auth->user, Sess->cname,
123 Sess->auth->windom, Sess->remos,
124 Sess->slip, Sess->mtu, Sess->isguest? "as guest": "");
126 fmtprint(f, "caps: ");
127 for(i = 0; i < nelem(captab); i++)
128 if(Sess->caps & captab[i].val)
129 fmtprint(f, "%s ", captab[i].name);
132 fmtprint(f, "security: ");
133 for(i = 0; i < nelem(sectab); i++)
134 if(Sess->secmode & sectab[i].val)
135 fmtprint(f, "%s ", sectab[i].name);
139 fmtprint(f, "transport: cifs over netbios\n");
141 fmtprint(f, "transport: cifs\n");
152 if((got = RAPsessionenum(Sess, &Ipc, &si)) == -1){
153 fmtprint(f, "RAPsessionenum: %r\n");
157 for(i = 0; i < got; i++){
158 fmtprint(f, "%-24q %-24q ", si[i].user, si[i].wrkstn);
159 fmtprint(f, "%12s ", period(si[i].sesstime));
160 fmtprint(f, "%12s\n", period(si[i].idletime));
169 * We request the domain referral for "" which gives the
170 * list of all the trusted domains in the clients forest, and
171 * other trusted forests.
173 * We then sumbit each of these names in turn which gives the
174 * names of the domain controllers for that domain.
176 * We get a DNS domain name for each domain controller as well as a
177 * netbios name. I THINK I am correct in saying that a name
178 * containing a dot ('.') must be a DNS name, as the NetBios
179 * name munging cannot encode one. Thus names which contain no
180 * dots must be netbios names.
184 dfsredir(Fmt *f, char *path, int depth)
186 Refer *re, retab[128];
189 n = T2getdfsreferral(Sess, &Ipc, path, &flags, &used, retab, nelem(retab));
192 for(re = retab; re < retab+n; re++){
193 if(strcmp(path, re->path) != 0)
194 dfsredir(f, re->path, depth+1);
196 fmtprint(f, "%-32q %q\n", re->path, re->addr);
219 if((got = RAPuserenum2(Sess, &Ipc, &nl)) == -1)
220 if((got = RAPuserenum(Sess, &Ipc, &nl)) == -1){
221 fmtprint(f, "RAPuserenum: %r\n");
225 for(i = 0; i < got; i++){
226 fmtprint(f, "%-24q ", nl[i].name);
228 if(RAPuserinfo(Sess, &Ipc, nl[i].name, &ui) != -1){
229 fmtprint(f, "%-48q %q", ui.fullname, ui.comment);
233 free(ui.user_comment);
245 int got1, got2, i, j;
246 Namelist *grps, *usrs;
249 if((got1 = RAPgroupenum(Sess, &Ipc, &grps)) == -1){
250 fmtprint(f, "RAPgroupenum: %r\n");
254 for(i = 0; i < got1; i++){
255 fmtprint(f, "%q ", grps[i].name);
257 if((got2 = RAPgroupusers(Sess, &Ipc, grps[i].name, &usrs)) != -1){
258 for(j = 0; j < got2; j++){
259 fmtprint(f, "%q ", usrs[j].name);
272 nodelist(Fmt *f, int type)
276 static char *types[] = {
286 [9] "printer server",
287 [10] "dial-up server",
293 [16] "potential browser",
294 [17] "backup browser",
302 [25] "Terminal server",
309 if((got = RAPServerenum2(Sess, &Ipc, Sess->auth->windom, type, &more,
311 fmtprint(f, "RAPServerenum2: %r\n");
315 if((got = RAPServerenum3(Sess, &Ipc, Sess->auth->windom, type,
317 fmtprint(f, "RAPServerenum3: %r\n");
321 for(i = 0; i < got; i++){
322 fmtprint(f, "%-16q %-16q ", si[i].name, si[i].comment);
323 if(type != LIST_DOMAINS_ONLY){
324 fmtprint(f, "v%d.%d ", si[i].major, si[i].minor);
325 for(j = 0; j < nelem(types); j++)
326 if(si[i].type & (1 << j) && types[j])
327 fmtprint(f, "%s,", types[j]);
340 return nodelist(f, LIST_DOMAINS_ONLY);
344 workstationinfo(Fmt *f)
346 return nodelist(f, ALL_LEARNT_IN_DOMAIN);
353 static char when[32];
355 days = sec / (60L * 60L * 24L);
356 sec -= days * (60L * 60L * 24L);
357 hrs = sec / (60L * 60L);
358 sec -= hrs * (60L * 60L);
362 snprint(when, sizeof(when), "%d %d:%d:%ld ", days, hrs, min, sec);
364 snprint(when, sizeof(when), "%d:%d:%ld ", hrs, min, sec);