+/*
+ * Deletes a file
+ */
+static NTSTATUS unlink_file(struct py_cli_state *self, const char *filename)
+{
+ NTSTATUS status;
+ uint16_t attrs = (FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+
+ if (self->is_smb1) {
+ struct tevent_req *req = NULL;
+
+ req = cli_unlink_send(NULL, self->ev, self->cli, filename,
+ attrs);
+ if (!py_tevent_req_wait_exc(self, req)) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+ status = cli_unlink_recv(req);
+ TALLOC_FREE(req);
+ } else {
+ status = cli_unlink(self->cli, filename, attrs);
+ }
+
+ return status;
+}
+
+static PyObject *py_smb_unlink(struct py_cli_state *self, PyObject *args)
+{
+ NTSTATUS status;
+ const char *filename = NULL;
+
+ if (!PyArg_ParseTuple(args, "s:unlink", &filename)) {
+ return NULL;
+ }
+
+ status = unlink_file(self, filename);
+ PyErr_NTSTATUS_NOT_OK_RAISE(status);
+
+ Py_RETURN_NONE;
+}
+