return retval;
}
+static NTSTATUS smb1_getatr(struct cli_state *cli,
+ const char *path,
+ uint16_t *pattr)
+{
+ uint8_t *bytes = NULL;
+ uint16_t *return_words = NULL;
+ uint8_t return_wcount = 0;
+ NTSTATUS status;
+
+ bytes = talloc_array(talloc_tos(), uint8_t, 1);
+ if (bytes == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ bytes[0] = 4;
+ bytes = smb_bytes_push_str(bytes,
+ smbXcli_conn_use_unicode(cli->conn),
+ path,
+ strlen(path)+1,
+ NULL);
+ if (bytes == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = cli_smb(talloc_tos(),
+ cli,
+ SMBgetatr, /* command. */
+ 0, /* additional_flags. */
+ 0, /* wct. */
+ NULL, /* vwv. */
+ talloc_get_size(bytes), /* num_bytes. */
+ bytes, /* bytes. */
+ NULL, /* result parent. */
+ 10, /* min_wct. */
+ &return_wcount, /* return wcount. */
+ &return_words, /* return wvw. */
+ NULL, /* return byte count. */
+ NULL); /* return bytes. */
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ *pattr = PULL_LE_U16(return_words, 0);
+ return status;
+}
+
+static bool test_smb1_getatr(struct cli_state *cli)
+{
+ NTSTATUS status;
+ bool retval = false;
+ bool ok = false;
+ uint16_t attrs = 0;
+
+ /* Start clean. */
+ (void)smb1_dfs_delete(cli, "\\BAD\\BAD\\getatrfile");
+
+ /* Create a test file. */
+ ok = smb1_create_testfile(cli, "\\BAD\\BAD\\getatrfile");
+ if (!ok) {
+ printf("%s:%d failed to create test file %s\n",
+ __FILE__,
+ __LINE__,
+ "\\BAD\\BAD\\getatrfile");
+ goto err;
+ }
+
+ /*
+ * We expect this to succeed, but get attributes of
+ * the root directory.
+ */
+ status = smb1_getatr(cli, "getatrfile", &attrs);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("%s:%d SMB1getatr of %s failed (%s)\n",
+ __FILE__,
+ __LINE__,
+ "getatrfile",
+ nt_errstr(status));
+ goto err;
+ }
+ if ((attrs & FILE_ATTRIBUTE_DIRECTORY) == 0) {
+ printf("%s:%d error expected SMB1getatr of file %s "
+ "to return directory attributes. Got 0x%x\n",
+ __FILE__,
+ __LINE__,
+ "getatrfile",
+ (unsigned int)attrs);
+ goto err;
+ }
+
+ /*
+ * We expect this to succeed, but get attributes of
+ * the root directory.
+ */
+ status = smb1_getatr(cli, "\\BAD\\getatrfile", &attrs);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("%s:%d SMB1getatr of %s failed (%s)\n",
+ __FILE__,
+ __LINE__,
+ "\\BAD\\getatrfile",
+ nt_errstr(status));
+ goto err;
+ }
+ if ((attrs & FILE_ATTRIBUTE_DIRECTORY) == 0) {
+ printf("%s:%d error expected SMB1getatr of file %s "
+ "to return directory attributes. Got 0x%x\n",
+ __FILE__,
+ __LINE__,
+ "\\BAD\\getatrfile",
+ (unsigned int)attrs);
+ goto err;
+ }
+
+ /*
+ * We expect this to succeed, and get attributes of
+ * the testfile.
+ */
+ status = smb1_getatr(cli, "\\BAD\\BAD\\getatrfile", &attrs);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("%s:%d SMB1getatr of %s failed (%s)\n",
+ __FILE__,
+ __LINE__,
+ "\\BAD\\BAD\\getatrfile",
+ nt_errstr(status));
+ goto err;
+ }
+ if (attrs & FILE_ATTRIBUTE_DIRECTORY) {
+ printf("%s:%d error expected SMB1getatr of file %s "
+ "to return non-directory attributes. Got 0x%x\n",
+ __FILE__,
+ __LINE__,
+ "\\BAD\\BAD\\getatrfile",
+ (unsigned int)attrs);
+ goto err;
+ }
+
+ retval = true;
+
+ err:
+
+ (void)smb1_dfs_delete(cli, "\\BAD\\BAD\\getatrfile");
+ return retval;
+}
+
/*
* "Raw" test of different SMB1 operations to a DFS share.
* We must (mostly) use the lower level smb1cli_XXXX() interfaces,
goto err;
}
+ ok = test_smb1_getatr(cli);
+ if (!ok) {
+ goto err;
+ }
+
retval = true;
err: