smbcomcreatedir.c 692 B

12345678910111213141516171819202122232425
  1. #include "headers.h"
  2. SmbProcessResult
  3. smbcomcreatedirectory(SmbSession *s, SmbHeader *h, uchar *, SmbBuffer *b)
  4. {
  5. int fd;
  6. char *path;
  7. uchar fmt;
  8. if (h->wordcount != 0)
  9. return SmbProcessResultFormat;
  10. if (!smbbuffergetb(b, &fmt) || fmt != 0x04 || !smbbuffergetstring(b, h, SMB_STRING_PATH, &path))
  11. return SmbProcessResultFormat;
  12. smblogprint(h->command, "smbcomcreatedirectory: %s\n", path);
  13. fd = create(path, OREAD, DMDIR | 0775);
  14. if (fd < 0) {
  15. smblogprint(h->command, "smbcomcreatedirectory failed: %r\n");
  16. smbseterror(s, ERRDOS, ERRnoaccess);
  17. free(path);
  18. return SmbProcessResultError;
  19. }
  20. close(fd);
  21. free(path);
  22. return smbbufferputack(s->response, h, &s->peerinfo);
  23. }