Github user HuJiayin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5307#discussion_r33741296
  
    --- Diff: 
core/src/main/scala/org/apache/spark/storage/BlockObjectWriter.scala ---
    @@ -123,12 +129,29 @@ private[spark] class DiskBlockObjectWriter(
        */
       private var numRecordsWritten = 0
     
    +  private var sparkConf:SparkConf = null
    +
       override def open(): BlockObjectWriter = {
         if (hasBeenClosed) {
           throw new IllegalStateException("Writer already closed. Cannot be 
reopened.")
         }
         fos = new FileOutputStream(file, true)
    -    ts = new TimeTrackingOutputStream(fos)
    +    val cryptoConf = CryptoConf.parse(sparkConf)
    +    if (cryptoConf.enabled) {
    +      val cryptoCodec: CryptoCodec = 
CryptoCodec.getInstance(CipherSuite.AES_CTR_NOPADDING)
    +      val bufferSize: Int = sparkConf.getInt(
    +        SPARK_ENCRYPTED_INTERMEDIATE_DATA_BUFFER_KB,
    +        DEFAULT_SPARK_ENCRYPTED_INTERMEDIATE_DATA_BUFFER_KB) * 1024
    +      val iv: Array[Byte] = createInitializationVector(cryptoCodec)
    +      val credentials = SparkHadoopUtil.get.getCurrentUserCredentials()
    +      var key: Array[Byte] = credentials.getSecretKey(SPARK_SHUFFLE_TOKEN)
    --- End diff --
    
    if you cannot get the user credential, you can write a default number to 
configuration file every time when a certain user started the jobs, and 
retrieve this number in such case.
    however, i think it maybe unsafe to store SPARK_SHUFFLE_TOKEN and related 
information in plain text in configuration file, it is better to cypher the 
texts then store the values.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to